[Prev][Next][Index][Thread]

Re: with-foo ( foo = args ) (was Re: Critique this macro, please)




Chris Page wrote in message ...
>in article GGv36.27094$1M.5921606@typhoon.ne.mediaone.net, Scott McKay at
>swm@mediaone.net wrote on 2000.12.30 5:08 PM:
>
>> I considered other syntaxes, but settled on this as the simplest.
>
>Yes, I can see the advantage of simpler syntax. But I find it a bit odd to
>put the binding name and the binding symbol within the parenthesis next to
>the arguments.


I put parens there because there are often keyword arguments
trailing the "binding form", and they need to be delimited somehow.
That's the best I could think of at the time...

>> I don't like yours for two reasons:
>> - '<=' doesn't say "bind" to me
>> - the naked parens after the '<=' look too, well, naked
>
>Well, that was just meant to evoke ideas on the topic. I'm curious what you
>thought of the other possibilities, such as "in", which seems in line with
>the "for" macro:
>
>    with-file-sequence( file in "foo.txt", delimiter: '\n' )


I don't like 'in' because it signals iteration over a collection to me.

>Perhaps the real problem here is restricting ourselves to ASCII. There
might
>be a much better symbol or symbols in Unicode, for example.
>
>Here are some other ideas:
>
>    with-file-sequence file from( "foo.txt", delimiter: '\n' )
>
>    with-file-sequence file using( "foo.txt", delimiter: '\n' )
>
>    with-file-sequence file in "foo.txt", delimiter: '\n' do
>
>(I kind of wish "for" had used a keyword like "do" to eliminate the
>parenthesis.)
>
>> It's probably not worth tweaking this convention at this point,
>> since all the Fun-O de facto "standard" libraries now use it...
>
>I think it's always worth thinking about how things might be improved, even
>if a particular instance won't be changed in the foreseeable future.
>
>In this particular case, I guess I'm interested in the larger question of
>what constitutes good macro syntax. It seems to me that restricting macros
>to lumping everything into a single list of items in parenthesis is overly
>simplistic. Even in Lisp, the binding name and the arguments would probably
>be separated into separate lists (this is a rough guess, I'm no Lisp
>expert):
>
>    (with-file-sequence (file) ("foo.txt" :delimiter '\n')
>
>or
>
>    (with-file-sequence ((file) ("foo.txt" :delimiter '\n'))


It's (with-open-file (stream file &rest keyword-args) ...body...)
All I did was add an '='!





References: