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

Ary Borenszweig ary at esperanto.org.ar
Tue Sep 3 11:26:56 PDT 2013


On 9/3/13 2:11 AM, monarch_dodra wrote:
> 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 ;)

"Today if anyone writes or sees sees mixin(stuff) they are well warned 
that arbitrary code generation is taking place and are ready to deal 
with the consequences."

When you do "import foo.bar" you are importing arbitrary code... If you 
are not sure what that does, you go look it up. And it's the same for 
implicit mixins. I don't see the issue at all...


More information about the Digitalmars-d mailing list