www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - New syntax idea for mixing overloads in a class using `mixin template`

I have posted here on Learn asking how would I be able to expand 
overloads using mixin template. As the mixin template generates a 
"namespace" for calling these functions when you need to 
overload, it creates a problem where you need to add `alias 
myFunc = myMixin.myFunc`.

And that is okay, until you have to define more than one 
function, it will lead to a lot of boilerplate code which is the 
total opposite reason which mixin template was created.

Check the full code here on my forum post:

https://forum.dlang.org/post/epugicostneoiebdqdtg forum.dlang.org

Then while I was asking for some better recommendations on what 
to do, `mixin ("things that I defined on mixin template")` came 
as an idea. Which totally made me wonder "well if I started doing 
that, it feels like mixin template becomes totally outdone by the 
string mixin.

Then while talking on discord, Paul gave an idea where those 
expansion could be totally mixed in the current scope and thus 
new overload sets by using the following syntax: `mixin 
MyMixinTemplate this`. Which would have the great feature of not 
breaking older code by doing that, beyond that, it would solve an 
old bug where you can't declare a constructor overload on mixin 
template: https://issues.dlang.org/show_bug.cgi?id=3332

It would be consistent with the current `alias myVar this` 
syntax, and it would be even clearer in the case that you are 
mixing the template inside the class, and thus, being able to 
even define a constructor inside the mixin template.
Jul 28 2022