On Friday, 25 April 2025 at 17:24:18 UTC, Andy Valencia 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. Like, is there a variant of the following which makes a function named "foo1" available?

Andy

```d
mixin template Foo(alias fn) {
    int fn() { return 1; }
}

mixin Foo!foo1;

void main() {
    import std.stdio : writeln;

    writeln(foo1());
}
```

If we ever get string mixins of identifiers maybe, but as is it wont go that well

like you have the identifier at programing time, use an alias `alias foo1=Foo(...)` if you need a list, use an int and specialization, you can then access it with `static foreach(I;0..N){`
if you have arguements, use a standard template
if you need to use features from a struct; use propertys of the struct in line of a meta program

Reply via email to