Dream Feature Regarding Default Arguments

Byron byron.heads at gmail.com
Tue Apr 8 12:23:01 PDT 2014


On Sat, 05 Apr 2014 21:26:17 -0400, Nick Sabalausky wrote:

> I realize this isn't the time for such a thing to be added to D, but I
> thought I'd put the idea out there, FWIW:
> 
> I find myself frequently needing to design APIs that work like this:
> 
>      func( [optionalFoo], [optionalBar] )
> 
> Typically, that's not permitted in C-style languages, including D. They
> only allow this:
> 
>      func( [optionalFoo, [optionalBar]] )
> 

static structs can be initialized by name, maybe that syntax could be 
expanded upon?

void foo( struct{ int a = 1; double b = 3.14; } ) { .. }
...
foo( {b: 2} );

that or named tuples with an init value set?


More information about the Digitalmars-d mailing list