Re: macro for shorter array syntax



Jon Harrop wrote:
I thought this was a trivial OCaml macro but it is apparently prohibitively
difficult to translate into Lisp.

The closest so far seems to be Pascal's:
which doesn't handle operator associativities and precedences.

This implies that OCaml macros can be easier which, in turn, justifies my
point about macros not being useful in languages that provide non-trivial
syntax.

I think some of the disagreement here is over the word "syntax". When
Lisp manuals and tutorials say macros define new syntax, they're usually
talking about the overall structure of the program, where WITH-macros
automatically allocate and deallocate resources, DO- macros implement
loops, etc.. What they never seem to mention is that almost all of this
syntactic transformation occurs within the standard sexpr convention.
Macros are not usually used for character twiddling, they're used
primarily to encapsulate program organization at a larger scale.

When I first read about Lisp macros, I also thought the manuals were
talking about character twiddling, and I was disappointed to find that
the manuals had glossed that over. I didn't mind so much that macros
weren't as good for going beyond sexpr syntax as for working within it,
it's just that it would have been nice if the manuals could have
explained that more clearly. That's what manuals are for: They're
supposed to explain things. If they don't do that, they're not doing
their job.

The same thing goes for experienced Lispers chatting on internet
newsgroups. Lisp is not optimized for trivial little exercises,
and yet we insist that it's just as good for character-twiddling
exercises as other languages with those features built in. I don't
think it is. I think some of the modern functional languages have
lots of sugary syntax and are very good at defining new forms of
syntax with even more sugar. The question for large-scale pro-
fessional software development is whether low-level sugar is more
important than encapsulating huge swaths of the entire program.
Would Camlp4 be good for implementing something like LOOP or CLOS
if someone really wanted it? Would it be good for implementing
something like Viaweb or any number of AI applications?

Even though this thread is here on c.l.l, we're allowing the conver-
sation to drift away from lisp-related subjects, while at the same
time denying that fact. No, Lisp macros are not optimized for low-
level character juggling. They're designed for more important things,
and we should stop insisting otherwise. All it does is provide food
for trolls and other people who wonder why they can't have their
favorite form of syntactic sugar and have no idea of the even more
useful features they're missing out on.

--
Dan
www.prairienet.org/~dsb/
.



Relevant Pages

  • Re: Very poor Lisp performance
    ... >>> Do you mean it is difficult to implement infix in Lisp? ... > to write macros that use infix syntax? ... your language is infix it's harder to write macros because the macros ...
    (comp.lang.lisp)
  • Re: Two questions together
    ... How powerful are the macros? ... > "programmable language" and as far as I know this feature is provided ... It is also said that one can hammer the Lisp so that ... I really love Lisp's syntax:) But I just want ...
    (comp.lang.lisp)
  • Re: eval in bash vs macro in lisp
    ... So although I don't understand LISP macros, ... the syntax of the language. ... You can't do that in bash. ...
    (comp.lang.lisp)
  • Re: Benefits of Dynamic Typing
    ... Many dynamically typed languages (e.g. Python, ... > So I think the assertion is only true if it is changed to "Lisp's syntax is ... > is "Lisp was designed to have a simple syntax". ... So there is syntax expressed via macros or built-in special forms. ...
    (comp.lang.functional)
  • Re: Cons cell archaic!?
    ... How would the implementation of a Lisp without a using cons look like? ... the irregularity in its often cited regular syntax. ... Lisp at core is based on functional programing on lists. ...
    (comp.lang.lisp)