Named arguments

bauss jj_1337 at live.dk
Wed Oct 25 15:33:05 UTC 2017


On Wednesday, 25 October 2017 at 14:58:50 UTC, jmh530 wrote:
> On Wednesday, 25 October 2017 at 12:40:47 UTC, Bastiaan Veelo 
> wrote:
>> [snip]
>>
>> int first = 1;
>> void main()
>> {
>>     // Ordinary:
>>     foo(first, 2, 3.0, "4");    // Prints one=1; two=2; 
>> three=3; four=4
>>     // Named arguments:
>>     named!(foo, "four", "4",
>>                 "two", 2,
>>                 "one", first,
>>                 "three", 3.0);  // idem
>> }
>
>
> You're passing the function arguments as template parameters. 
> Usually you want them to be able to be passed at run-time.

That depends. It's a common pattern in D to pass them as template 
parameters, in fact most functionality in std.algorithm supports 
it.


More information about the Digitalmars-d mailing list