> The array concatenation requiring GC I get, but why does a 
> delegate require it?

If you really want a stack allocated delegate, you could use something like:

import std.stdio, std.traits;

struct DelegateWrapper(alias fun, Args...)
{
    Args args;
    private auto f(ParameterTypeTuple!fun[Args.length..$] otherArgs)
    {
        return fun(args, otherArgs);
    }
    auto dg()
    {
        return &f;
    }
}

auto delegateWrapper(alias fun, A...)(A a)
{
    return DelegateWrapper!(fun,A)(a);
}

void main()
{
    static test (int a, int b, int c)
    {
        writeln(a, b, c);
    }
    auto b = delegateWrapper!(test)(1,2);
    
    b.dg()(3);
}


Reply via email to