mixin identifiers concept

Nick Treleaven nick at geany.org
Wed Feb 2 12:24:32 UTC 2022


On Wednesday, 2 February 2022 at 12:19:57 UTC, Ola Fosheim 
Grøstad wrote:
> String mixins should be discouraged, not encouraged. Adding 
> more band aids or special cases is not the right approach.

String mixins can be used for declarations, expressions or types. 
The special case is actually that they can't be used for an 
identifier. People even expect that to work - from the learn 
forum:

https://forum.dlang.org/thread/ngfkwcyqjtnqhofoqrew@forum.dlang.org

> If compile time string processing is the root issue then one 
> shouldn't solve that by changing the semantics of mixin(). That 
> performance issue can be fixed by introducing classic string 
> interpolation.

String interpolation would be pretty much just as bad for 
performance because it still requires the entire declaration to 
be put in a string, rather than just an identifier. That whole 
string needs to be formatted and turned into code, when we'd 
rather be reading code in the first place!




More information about the Digitalmars-d mailing list