From: Vijay L
Subject: Re: doubts on a macro generating HTML
Date: 
Message-ID: <1eaf81aa.0212130557.e6087a@posting.google.com>
Kenny Tilton <·······@nyc.rr.com> wrote in message news:<················@nyc.rr.com>...
> Vijay L wrote:
[snip][snip]
> > 
> > I have two questions:
> > (1) Is there a way to improve upon efficiency in my macro? I create a
> > list of length equal to the number of attributes in the tag, surely
> > there is a better way to do it.
> 
> I thought I saw two lists, one for the names and one for the values. If 
> you pass them in as the original 'pairs', some loop expert here will 
> explain how to write that loop clause to destructure them in the loop. 
> something like "(loop for (name value) in pairs..." (total fiction that, 
> I do not know loop).

My mistake. There were two lists created, I overlooked the ',(mapcar
...) list.
I will try the loop construct myself and hopefully not have to ask for
help on it. Thanks for the idea.

> And don't call me Shirley. (joke from a movie you might not know)

I don't know the movie, could you tell me the name of the movie? I'll
see if I can get my hands on it.
 
> > (2) My macro is still irritating to write in one aspect: I have to
> > specify OUTPUT-STREAM everytime. At first I thought of keeping a
> > special variable (say), *html-stream*, that would be set everytime I
> > was starting to write a html file. This would be specified with
> > another macro (say), START-HTML, like this:
> > (start-html output-stream
> >   (output->html ...))
> > While this is ok if my html file is going to write everything to only
> > one stream. I may (actually, I don't know that I will not) find myself
> > in some situation where I have to write to another html stream. Again,
> > this I can implement by treating the special variable as a stack, but
> > this seems ugly too.
> 
> Well special variables are perfect for doing this kind of stack-y thing 
> without ugliness. Quite beautiful, actually. You do not even need a 
> special start-html macro to do it:
> 
> (let ((*html-stream* output-stream))
>      (output->html ...))
> 
> Now some requirement comes along to, say, while generating the html to 
> also generate a log of something going on deep in the innards of your 
> logic, such as how often each tag is used. 

> (Go with me on this <g>) 

Like I said, I don't know that I will not have a use for the same. So,
I am willing to believe anything as long as it is quite incredible -
Oscar Wilde.

> And it is decided that the log should be in html! No problem:
> 
> (defun log-usage (tag)
>     (let ((*html-stream* *log-stream*)) ;; log stream set elsewhere
>         (log-that-tag tag)))
> 
> ...and thru the miracle of special variables *html-stream* reverts to 
> output-stream's value as soon as the let form which bound it to 
> *log-stream* exits.

Oh! I was almost on the right track! Thanks.

> > 
> > I am proud to say that I wrote the macro first and *then* came across
> > the term ``variable capture'' in 'On Lisp.'
> 
> That is really sick. You'll go far in Lisp. :)

Thanks for the compliment.

> > 
> > Can variable capture be done in some other language? From the little I
> > know of Scheme, I know that it is *not* possible in Scheme.
> 
> COBOL is all-capture-all-the-time. :)

That's one. Thankfully we were spared the misery of having a COBOL lab
college; my senior batch had to go thru it.

Thanks,

Vijay L

If I were given a dime for every time someone asked me: "Can you do
that in Lisp?", I'd be rich.
From: Kenny Tilton
Subject: Re: doubts on a macro generating HTML
Date: 
Message-ID: <3DFA1012.1070904@nyc.rr.com>
Vijay L wrote:
> Kenny Tilton <·······@nyc.rr.com> wrote in message news:<················@nyc.rr.com>...
> 
> My mistake. There were two lists created, I overlooked the ',(mapcar
> ...) list.
> I will try the loop construct myself and hopefully not have to ask for
> help on it. Thanks for the idea.

OK. I /really/ do not know loop or I would take a second guess at the 
syntax based on something i saw in a recent post. but I am sure you need 
not generate extra lists to do what you want.

> 
> 
>>And don't call me Shirley. (joke from a movie you might not know)
> 
> 
> I don't know the movie, could you tell me the name of the movie? I'll
> see if I can get my hands on it.

"Airplane". A little dated, but astonishing (and hilarious) at the time.

>>...and thru the miracle of special variables *html-stream* reverts to 
>>output-stream's value as soon as the let form which bound it to 
>>*log-stream* exits.
> 
> 
> Oh! I was almost on the right track! Thanks.

It's really an amazing feature. Globals are generally Bad Things, but 
for cases like this they are brillo.



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore