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

Don nospam at
Thu Oct 8 01:00:01 PDT 2009

Bill Baxter wrote:
>> On Wed, Oct 7, 2009 at 11:21 AM, Don <nospam at> 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:
> 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.

Only with trivial examples. With more complicated examples they look 
less identical. I'm basing my views on pages like this:

Unless I'm totally misunderstanding this, it looks to me as though 
Nemerle macros are implemented as compiler plugins.
All the advanced facilities are obtained by exposing the compiler's API!

I pesonally think that is an utterly revolting thing to add to a language.
Compare with macros in Lisp and Forth.

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

I do think it's a profoundly bad idea in a C-like language, but it's not 
what I'm referring to here.

More information about the Digitalmars-d-learn mailing list