How about macro == symbol for mixin statement? [was Re: Member functions C to D]

Bill Baxter wbaxter at gmail.com
Wed Oct 7 11:05:35 PDT 2009


> On Wed, Oct 7, 2009 at 11:21 AM, Don <nospam at nospam.com> wrote:

>> By contrast, something like Nemerle macros are a kludge. The idea of
>> providing a 'hook' into the compiler is a horrible hack. It exposes all
>> kinds of compiler internals. Yes, it has nicer syntax.

Are you talking specifically about the ability to define new syntax?
Because it looks to me that one can use nemerle macros just fine
without defining new syntax.
I'm getting that from here: http://nemerle.org/Macros_tutorial

Here's just a simple macro that adds no new syntax from that page:

macro m () {
  Nemerle.IO.printf ("compile-time\n");
  <[ Nemerle.IO.printf ("run-time\n") ]>;
}

module M {
  public Main () : void {
    m ();
  }
}


That seems significantly more elegant to me than

string m() {
   pragma(msg, "compile-time");
   return q{writefln("run-time");}
}
void main() {
   mixin(m());
}

So it looks to me like the mechanics of it are basically identical.
Just Nemerle's syntax is nicer.

If you want to condem Nemerle's ability to define new syntax, I think
that should be taken up as a separate matter.

--bb


More information about the Digitalmars-d-learn mailing list