DIP idea: q{}-inspired block mixins

Paul Backus snarwin at gmail.com
Fri Nov 6 01:33:59 UTC 2020

On Friday, 6 November 2020 at 01:06:28 UTC, Q. Schroll wrote:
> Something like that has been proposed before, called "mixin 
> identifiers"; everywhere an Identifier would be valid, one 
> could use a string mixin to generate and splice in the 
> identifier. Of your example,
> mixin template property(T, string name)
> {
>     private T mixin(name)_;
>     T mixin(name)() { return mixin(name)_; }
> //    -----------
> }
> only the highlighted part would word. The other parts don't 
> make sense; mixins don't "connect" with surrounding tokens. If 
> `name` is "prop", `mixin(name)_` cannot become `prop_`. No kind 
> of mixin does that; not even my DIP proposes that.

This is trivially fixed by changing `mixin(name)_` to 
`mixin(name, "_")`.

> Maybe I'll make Mixin Identifiers part of the DIP. Let me know 
> what you think.

Better to make them two separate DIPs. They're completely 
independent features, after all.

More information about the Digitalmars-d mailing list