On Thu, Nov 19, 2009 at 9:48 PM, Don <nos...@nospam.com> wrote:
> Now that we have struct literals, the old C-style struct initializers don't
> seem to be necessary.
> The variations with named initializers are not really implemented -- the
> example in the spec doesn't work, and most uses of them cause compiler
> segfaults or wrong code generation. EG...
>
> struct Move{
>   int D;
> }
> enum Move genMove = { D:4 };
> immutable Move b = genMove;
>
> It's not difficult to fix these compiler problems, but I'm just not sure if
> it's worth implementing. Maybe they should just be dropped? (The { field:
> value } style anyway).

I agree there are too many ways to make structs, but...

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...)

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)

--bb

Reply via email to