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

monarch_dodra monarchdodra at gmail.com
Tue Sep 3 01:45:24 PDT 2013


On Tuesday, 3 September 2013 at 08:23:57 UTC, Timothee Cour wrote:
>> Long story short, you are basically asking for macro. If we
>> allowed this, than anything could actually be code injection, 
>> and
>> mean anything.
>
>
> No, only mixin statements and @mixin functions. And a regular 
> function
> calling a @mixin function would still be regular, eg not able 
> to access
> symbols in enclosing scope by name.

But that sill implies knowing exactly *what* is called, eg 
knowing the documentation of everything that is used, as opposed 
to just knowing "that *looks* like a function call that *does* 
something or other", but not worrying about it more than that.

Allowing implicit mixin adds an entire extra level of 
"dereference" when reading wode.

>>
>>  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.
>>
>
> What do you mean by "nothing would ever come after the mixin" ?
> You can have: some_string.embed.mixin.writeln;

Hadn't thought of that.


More information about the Digitalmars-d mailing list