Where are we with thoughts on string interpolation and mixins?
Adam D. Ruppe
destructionator at gmail.com
Tue Nov 20 15:28:07 UTC 2018
On Tuesday, 20 November 2018 at 10:09:40 UTC, Zoadian wrote:
> replace("%T%", T.stringof).replace("%TC%",
> TC.stringof).replace("%TI%", TI.stringof);
Your case is an exception to the general rule, but I wanna point
out to other people reading that stringof in mixins is actually
*usually* a mistake and you are *usually* better off just using
the TC etc names directly in the mixin string. stringof breaks
with different scopes and even some symbol names/strings in a new
parsing context.
The big exception is function names... and tbh I kinda prefer to
give it an internal name and only mix in a public alias for it.
But that depends on the situation (and oh i wish we could change
the name more easily with an external trick or something, would
make static foreach more useful too!)
more info i wrote up a few years ago:
https://stackoverflow.com/questions/32615733/struct-composition-with-mixin-and-templates/32621854#32621854
More information about the Digitalmars-d
mailing list