proposal: @mixin functions to auto-mixin at call site

monarch_dodra monarchdodra at gmail.com
Mon Sep 2 22:11:07 PDT 2013


On Tuesday, 3 September 2013 at 04:15:17 UTC, Timothee Cour wrote:
> I'd like to be able to declare a function with a special @mixin 
> property
> that will auto-mixin at call site

Kenji had apparently implemented this:
https://github.com/D-Programming-Language/dmd/pull/459

But pulled out. This recent thread should sum it up:
http://forum.dlang.org/thread/yaasjclvyobpeftgwmke@forum.dlang.org

Long story short, you are basically asking for macro. If we
allowed this, than anything could actually be code injection, and
mean anything.

> If for some reason we can't have @mixin special property, can 
> we at least
> have UFCS for mixin, so that we could write:
> "variables: x1=$x1, x2=$x2, sum=$(x1+x2)".embed.mixin

I'm not sure this us very interesting (why not though), since
nothing would ever come after the mixin.

I'd still rather have "typeof" be UFCS-able:
5.typeof.stringof.writeln();

If we only got to choose 1 that is ;)


More information about the Digitalmars-d mailing list