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

Re: Macros Make Me Mad

Michael Vanier wrote:

>This is a very nice analysis.  I remember years ago hearing someone say
>that lisp programmers only care about ugly syntax for the amount of time
>that it takes to write a macro that packages it up into nice syntax.
>Given that, I'm curious as to why needle doesn't use s-expression syntax.
>For me, the big win with sexps is that macros don't look any different from
>standard function calls; only the evaluation is different (I'm excluding
>read-macros here). 
Well, I think the really big win is that users learn to think of 
programs as trees, not as
long text strings, and that therefore it's easier to write macros, since 
macros are
basically a thing that transforms one tree into another.  If you have a 
language, you have to figure out how to present it as a tree to the 
in such a way that the mapping from the language's textual syntax into a 
structure is very simple and natural.  This is what Jonathan Bachrach's Java
semantic extended accomlishes for Java.

>Incidentally, the thing that scares *me* about macros is debugging code
>that involves a lot of macros.  Can the debugger know enough about the
>macro definitions to allow the user to debug transparently without having
>to look at big macro expansions all the time?  Considering that C++
>debuggers have trouble dealing with simple macro-like constructs such as
>templates (or at least they used to) I assume that this is a non-trivial
Yes, it is.  One mitigating factor is that many macros in real life have 
"bodies" that often turn
out to be easy to debug with the debugging tools.