Pretty please: Named arguments

Jacob Carlborg doob at me.com
Mon Feb 28 23:46:35 PST 2011


On 2011-02-28 21:44, Adam Ruppe wrote:
> Steven Schveighoffer:
>> But other than that, it still looks more verbose than should be
>> necessary.
>
> This is the real problem.
>
> We already have named arguments in today's D. You can do some stringof
> magic to get the parameter names and ParameterTypeTuple to assign them.
>
> I haven't written it, but there should be no blocker in combining these:
>
> void foo(int width, int height);
>
> auto args = NamedParameterTypeTuple!(foo);
>
> args.width = 10;
> args.height = 20;
>
> foo(args);
>
>
> But, that's just like the struct for length of code...
>
>
> If someone wanted to write the code to add the foo(width:10, height:10), I
> wouldn't likely object to it's inclusion. But, I
> don't see it as a big deal.

http://dsource.org/projects/orange/browser/orange/util/Reflection.d#L135

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list