opMixin or mixin function templates with convenience operator?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Thu Dec 12 11:39:46 UTC 2019

On Thursday, 12 December 2019 at 10:33:21 UTC, aliak wrote:
> struct interpolator {
>   void opMixin!(string)() {
>   }
> }
> // globally declared interpolator
> interpolator i;

Ok, so this is interesting, in the sense that you can have a 
runtime configured interpolator that can take localization for 
various countries into account.

But opMixin should take any parameter, not just string.

so you could do:


> Advantages over template mixins include that this has a return 
> type so it can be used to create things out of the current 
> context and give you something back.


It could be used for composition at runtime.

But how do you type check the resulting code?

This is getting close to AST macros... but you should be able to 
put constraint on the resulting AST.

More information about the Digitalmars-d mailing list