Mixin helper help

bauss jacobbauss at gmail.com
Sat Jan 14 02:51:56 UTC 2023


On Friday, 13 January 2023 at 16:54:34 UTC, Ali Çehreli wrote:
> On 1/13/23 00:48, bauss wrote:
>
> > 1. Change your mixin template to something like this:
>
> There was a technique as a workaround for this template mixin 
> limitation but I can't find it right now.
>
> > 2. Change the place where you instantiate to this:
>
> I think the workaround I am trying to remember would not 
> require any change for the users.
>
> Ok, it was something like this:
>
> mixin template myStatement() {
>     auto doIt() {
>         import std.stdio : writeln;
>         writeln("hi");
>         return 0;
>     }
>
>     auto ignoreThis = doIt();
> }
>
> void main() {
>     mixin myStatement!();
>     mixin myStatement!();
> }
>
> Ali

That's a good one!


More information about the Digitalmars-d-learn mailing list