[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how expressive are they?
>What I'd like to see is an example of a program, in a language with easy
>syntax for assignment and blocks, where rewriting it without any
>user-defined macros would be similarly painful. Several people so far
1. I guess you include the ability to redefine the name-space in the
evaluation context (compilation or run-time) in your definition of
"assignment and blocks"?
2. Can the mechanism you seem to be wanting to compare macros
to.. (viz. blocks+assignment) make the notation for any arbitrary code,
(including blocks+assignment "itself") more concise?
3. In your HTML from Perl example, if all this was done at "run-time"
how did you debug production systems that you did not have access to?
(The compile-time vs. run-time distinction for data-driven programs
is not a trivial one).
Personally, I think this comparison along the expressive power
dimension alone is somewhat pointless (it begins to sound like an
Emacs vs. VI discussion after a while). At some gross level all
languages are Turing complete, and I don't think people make the
decision to migrate to new languages or invent new ones purely because
the expressive power of the older ones are inadequate. Consider Prolog
and constraint-programming languages and even look at Lisp packages
like Screamer -- and then turn around and look at Java or C#.
> Do macros offer *anything* other than shorter programs?
Gee.. I'd turn that around and ask of languages that don't have macros
.. "what do you offer me in terms of facilities to write shorter
programs?" It's not exactly a small advantage :)
Anecdotally, I went and grepped through our pretty large code base
(the portions that are in Lisp), and was a bit surprised when I didn't
see that many macros as I expected to. I'd say 60-70% could probably be
replaced in-place w/ closure-style w/ no effect on the callees.. but
the remaining might be a bit harder.
>Guy's parodies are instructive, because they make you think about what
>you could afford to lose. Losing algebraic syntax (as opposed to
>Lisp-style arithmetic) is not too painful. Losing classes is a bit more
>painful. Losing functions makes programming very difficult indeed. So
>where do macros fit in this order?
Trevor -- Personally speaking, I've found the loss of macros really
painful on those occasions when I've really needed them -- think "a
deadline to get something up and running by 9 am tomorrow, and several
pages of repetitive code to write, but no time to write an entire
parser/rewriter/pre-processor/code-generator" :) (but I agree that I
don't view macros as indispensable as say functions).