Re: A "killer" macro
- From: Kent M Pitman <pitman@xxxxxxxxxxx>
- Date: 12 Sep 2007 10:02:35 -0400
Rainer Joswig <joswig@xxxxxxx> writes:
I also can't see why
(with-input-file (in filename)
(do-something in))
is better than
(call-with-input-file filename do-something)
1. Because of indentation issues. The former makes more textually
appropriate use of visual space.
2. Because of aesthetic issues that amount to a religious divide and that
may or may not appeal to you, but that are real to many. In the history
of mathematics, there was a longstanding confusion about the difference
between a function and an expression, owing in part to notations like
/
| x^2 dx
/
or if you prefer Lisp notation:
(integral (^ x 2) x)
rather than:
int(f) where { f(x) = x^2 }
There are some people who think that the change was a big improvement
and others who find it cumbersome to think of integrals this way. See
my 1980 paper on macros
( http://www.nhplace.com/kent/Papers/Special-Forms.html )
for the issues surrounding why people write macros and yet why it's useful
to be able to get at the functional form. I think both are important.
I used to program in a world, around 1978 when I arrived to Lisp, where
LET was a macro users had to write and we wrote everything as
((lambda (x) ...) binding-for-x)
The problem was that it made things execute backwards [first the binding
then the body, which was textually to the left or above]. Macros give
you control of that, too (especially important if your language is not
lazy).
3. A logical extension of your argument is to suggest that IF has no purpose
as a macro, and people should write a function:
(*if test (lambda () consequent) (lambda () alternative))
If you don't see that some of this is just syntactic baggage, you won't
get this argument. Making a lambda just to consume it is like the user
doing the system's job. And that's how people feel about
(call-with-input-file filename do-something)
when the do-something is
(call-with-input-file filename (lambda (stream) ...))
Every word there has a purpose except the lambda, which is just going to
get opened back into a function body instantly, and which in the meantime
is only further increasing indentation, and doing so EVEN IF you move it
to a new line, since it costs you three lines to get even close to where
the other would have done
(call-with-input-file filename
(lambda (stream)
...))
And even then if you want to give "options" you can't see them at the start
where you are going to need to if reading top-to-bottom/left-to-right,
you'll see them at the end, out of order from the evaluation order.
I am NOT trying to say that you should believe these arguments, but can you
see how some of these things would matter to others?
.
- Follow-Ups:
- Re: A "killer" macro
- From: Rainer Joswig
- Re: A "killer" macro
- References:
- A "killer" macro
- From: Eli Bendersky
- Re: A "killer" macro
- From: Pascal Costanza
- Re: A "killer" macro
- From: Thomas F. Bur***
- Re: A "killer" macro
- From: Rainer Joswig
- A "killer" macro
- Prev by Date: Re: A "killer" macro
- Next by Date: Re: What's ANSI Up To?
- Previous by thread: Re: A "killer" macro
- Next by thread: Re: A "killer" macro
- Index(es):