Re: Teaching new tricks to an old dog (C++ -->Ada)

From: Paul Mensonides (leavings_at_comcast.net)
Date: 03/29/05


Date: Tue, 29 Mar 2005 02:22:36 -0800

jayessay wrote:
> "Paul Mensonides" <leavings@comcast.net> writes:

>> Lisp macros cannot produce partial syntax either, whereas C/C++
>> macros can (e.g. on macro can create a '{' and another separate
>> invocation can create the closing '}').
>
> Again, that would be the sort of thing you would use reader macros.
> It's worth noting again that Lisp macros (the kind you generally mean
> when unqualified) do not work on text, they work on the syntax trees
> passed to them.

Neither do macros in C or C++. They operate on tokens. In any case, the
difference is meaningless. The only thing that matters is what the semantics
are (such as name binding). Lisp macros are easily inferior to Scheme macros in
that sense.

>> Jerry is correct to say that they do similar things--they parametize
>> code with code.
>
> But that is not really what they do. It is _one_ thing you can _use_
> them to do.

That is exactly what they do. It is irrelevant whether that code is in the form
of a syntax tree or not. The kind of thing that you seem to be referring to is
what Haskell does instead.

>> The main differences is that in Lisp (etc.) their
>
> I think the main differences are the ones I listed.

Obviously.

Regards,
Paul Mensonides



Relevant Pages

  • Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... that would be the sort of thing you would use reader macros. ... > It's worth noting again that Lisp macros (the kind you generally mean ... > when unqualified) do not work on text, they work on the syntax trees ...
    (comp.lang.ada)
  • Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... >> Can Lisp macros manipulate the text of the macro arguments? ... Lisp macros are like C/C++ ... macros in a pretty major way: they parametize code with code. ... > The/a cpp is a, well, preprocessor. ...
    (comp.lang.cpp)
  • Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... >> Can Lisp macros manipulate the text of the macro arguments? ... Lisp macros are like C/C++ ... macros in a pretty major way: they parametize code with code. ... > The/a cpp is a, well, preprocessor. ...
    (comp.lang.ada)
  • Re: macros (was: Paul Grahams teaching style is bad}
    ... > Agreed, that's just textual substitution. ... > not be done with C macros. ... not all things that can be done with Lisp macros can be done ... Here's a silly example but one that don't think has an analog in CPP: ...
    (comp.lang.lisp)
  • Re: Python syntax in Lisp and Scheme
    ... And Lisp macros are a ... "lots of things you can do with Lisp macros are impossible to do in ... HOFs, but instead imperative assignment is used, or macros. ... >> language constructs ...
    (comp.lang.python)