Python syntax in Lisp and Scheme
Neelakantan Krishnaswami
neelk at cs.cmu.edu
Mon Oct 6 10:29:27 EDT 2003
In article <blr1cq$bb1$1 at enyo.uwa.edu.au>, gregm at cs.uwa.edu.au wrote:
> In comp.lang.functional Erann Gat <my-first-name.my-last-name at jpl.nasa.gov>
> wrote:
>:> I can't see why a LISP programmer would even want to write a macro.
>: That's because you are approaching this with a fundamentally flawed
>: assumption. Macros are mainly not used to make the syntax prettier
>: (though they can be used for that). They are mainly used to add features
>: to the language that cannot be added as functions.
>
> Really? Turing-completeness and all that... I presume you mean
> "cannot so easily be added as functions", but even that would
> surprise me. (Unless you mean cannot be added _to_Lisp_ as
> functions, because I don't know as much as I'd like to about Lisp's
> capabilities and limitations.)
You know Haskell. Think about the do-noatation for monads: it takes
what would be awkward, error-prone code (using >> and >>= manually)
and makes it pleasant and readable. Do-notation is basically a macro
(and can easily be expressed as such in Scheme or Lisp). Syntactic
convenience is very important; consider how many fewer programmers in
ML are willing to reach for a monadic solution, even when it would be
appropriate. Or for that matter, think how many fewer Java programmers
are willing to write a fold than in ML or Haskell, even when it would
be appropriate.
--
Neel Krishnaswami
neelk at cs.cmu.edu
More information about the Python-list
mailing list