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

Here's one thing I just found:
struct constructors don't work at compile-time:

struct Struct
{
    this(int _n, float _x) {
        n = _n; x = _x;
    }
    int n;
    float x;
}

enum A = Struct(1,2);

// Error: cannot evaluate ((Struct __ctmp1;
// ) , __ctmp1).this(1,2F) at compile time

The C-style initializer works.
static opCall works too.

But if that bug is fixed, then I can't think of a reason to have the
classic C-style no-colons syntax.

--bb

Reply via email to