with(auto x = ...)

via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 24 08:16:25 PDT 2015


On Friday, 24 July 2015 at 15:01:29 UTC, Adam D. Ruppe wrote:
> On Friday, 24 July 2015 at 14:48:30 UTC, Marc Schütz wrote:
>> But I fail to see the relation to named parameters?
>
> You can make your parameters into a struct or tuple and fill 
> them in with normal assignment. The with(auto) thing will 
> conveniently limit the scope of the temporary argument object 
> and give a bit of syntax sugar for it:
>
> with(auto args = ParameterTypeTuple!foo) {
>    argname = cool;
>    argname2 = whatever;
>    foo(args);
> }
>

Nice!


More information about the Digitalmars-d mailing list