On Fri, Apr 25, 2025 at 05:24:18PM +0000, Andy Valencia via Digitalmars-d-learn 
wrote:
> On Friday, 25 April 2025 at 16:59:16 UTC, monkyyy wrote:
> > its extremely unclear what your trying to do my best geuss:
> 
> I want to use a mixin template to generate a top-level function.

Your best bet actually is to use a string mixin.  The quoted token
string can help make the generating code more readable. For example:

```d
        string makeFunc(string name) {
                return q{
                        int }~name~q{() {
                                return 1;
                        }
                };
        }

        mixin(makeFunc("myfunc"));

        void main() {
                assert(myfunc() == 1);
        }
```


T

-- 
I see that you JS got Bach.

Reply via email to