Can we drop static struct initializers?

Walter Bright newshound1 at digitalmars.com
Fri Nov 20 10:29:14 PST 2009


Bill Baxter wrote:
> 1) Struct literals don't work if you have an opCall for your struct.
>     (Maybe that's not such a big deal now that structs have
> constructors?  I haven't had a chance to look into struct constructors
> yet...)

Worst case, you can still construct them dynamically.

> 2) The field:value style struct initializer is probably the closest D
> will ever get to named arguments.  I think perhaps it should require
> the struct name, and be treated as a struct literal rather than static
> initializer:
> 
>       auto anS = S{D:4};   <=>   auto anS = S(4)

I think we'd need a compelling use case for why this is needed.



More information about the Digitalmars-d mailing list