inlining...

David Gileadi gileadis at NSPMgmail.com
Fri Mar 14 13:51:50 PDT 2014


On 3/14/14, 1:42 PM, Paulo Pinto wrote:
> Am 14.03.2014 19:09, schrieb David Gileadi:
>> On 3/13/14, 11:21 PM, Manu wrote:
>>> My feeling is that an ideal solution would be something like an
>>> enhancement which would allow the 'mixin' keyword to be used with
>>> regular function calls.
>>> What this would do is 'mix in' the function call at this location, ie,
>>> effectively inline that particular call, and it leverages a keyword and
>>> concept that we already have. It would obviously produce a compile error
>>> of the code is not available.
>>>
>>> I quite like this idea, but there is a potential syntactical problem;
>>> how to assign the return value?
>>>
>>> int func(int y) { return y*y+10; }
>>>
>>> int output = mixin func(10); // the 'mixin' keyword seems to kinda 'get
>>> in the way' if the output
>>> int output = mixin(func(10)); // now i feel paren spammy...
>>> mixin(int output = func(10)); // this doesn't feel right...
>>>
>>> My feeling is the first is the best, but I'm not sure about that
>>> grammatically.
>>
>> Is there already some trait for getting the string value of a function
>> including its code? If so then a mixin plus a small helper function
>> might do the job. If not then is such a trait feasible?
>
> Might be problematic with modules delivered only in .di + binary form.
>
> --
> Paulo

Quite, but as Manu says about his proposed solution,

> It would obviously produce a compile error
> of (sic) the code is not available.

This would need to behave similarly.


More information about the Digitalmars-d mailing list