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?

Reply via email to