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

Steven Schveighoffer schveiguy at yahoo.com
Wed Oct 7 07:09:03 PDT 2009


On Wed, 07 Oct 2009 09:17:59 -0400, Jarrett Billingsley  
<jarrett.billingsley at gmail.com> wrote:

> It's also insanely kludgy and ugly. Bleh.

If all a macro did was translate a scoped normal symbol to a mixin (or  
other macro) statement, would this take care of the ugliness? (would also  
be an insanely simple solution)

i.e.

macro doit(x, y, z) mixin("x" ~ "y" ~ "z"); // allow easy syntax for  
quoting parameters, since mixins are all about stringification.

doit(a, b, c) => mixin("abc");

Another example, logging:

class Logger
{
   ...
   macro logError(msg) mixin("{if(this.level >= ERROR)  
logMessage(this.level.Error, msg);}");
}

usage:

log.logError("bad error occurred with object: " ~  
expensiveObjectStringification(obj));

No more lazy parameters, no more stupid delegates :)

-Steve


More information about the Digitalmars-d-learn mailing list