proposal: @mixin functions to auto-mixin at call site
deadalnix
deadalnix at gmail.com
Thu Sep 5 03:51:17 PDT 2013
On Thursday, 5 September 2013 at 10:36:40 UTC, Dicebot wrote:
> On Wednesday, 4 September 2013 at 17:10:32 UTC, Timothee Cour
> wrote:
>> frankly, UFCS mixin would make the use case in the OT bearable.
>>
>> fun().mixin.writeln is ok
>> mixin(fun()).writeln is ugly (esp in more complex cases).
>>
>> so, is there anything against it despite requiring one to
>> implement it?
>
> I guess there is nothing terrible but also nothing extremely
> useful :) For me second snippet is not any uglier.
Stuff like data validation, or lazy initialization, anything
really data oriented usually benefit from that.
Also, the dichotomy function call/field access is really not that
clear at the end. Accessing some data may require a function
call, go through a signal handler, or involve complicated
operation by the CPU (potentially 2 round trip to memory).
On the other hand, optimizer will remove many function calls
making them effectively field access. Even if it isn't inlined, a
simple function call could end up being faster than 2 round trip
to memory (the stack is hot).
More information about the Digitalmars-d
mailing list