stringof and mixins when the types aren't available
David Nadlinger
code at klickverbot.at
Sun Jun 16 17:36:39 PDT 2013
On Monday, 17 June 2013 at 00:27:07 UTC, David Nadlinger wrote:
> The fix is simple: Replace `mixin(T.stringof ~ ".init")` by
> `return mixin("T.init")`. I am not mocking you here, using
> .stringof for codegen is amost always a bug, and it is usually
> possible to rewrite the code in such a way that just
> template-local names are used.
To expand on that a bit: In the case of default parameters,
instead of trying to directly generate a string representation
for them, you would instead design your (possibly complex) string
mixin logic such that the result string contains appropriate
instantiations of ParameterDefaultValueTuple to be resolved at
the point where you actually mix in the string.
David
More information about the Digitalmars-d
mailing list