On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote:
Maybe std.functional.partial can help you.

Nope.

        int i = 1;
        alias dg = partial!(writeln, i);
        i = 2;
        dg();

still prints '2' as it should because 'partial' takes 'i' as a symbol, which is - for this purpose - kinda like "by reference".

Anyway, I solved my problem already a while ago by replacing delegates with custom struct's that implement the call-operator. I started this thread just out of curiosity, because as I see it, the purpose of lambdas is pretty much to remove the need for such custom constructions.

Reply via email to