DMD 1.035 and 2.019 releases
bobef
bobef at nosmap-abv.bg
Wed Sep 3 22:11:36 PDT 2008
Walter Bright Wrote:
> bearophile wrote:
> > Walter Bright:
> >> If there's any constructor defined for S, then S(args) is a
> >> constructor call. If there's any opCall defined for S, then S(args)
> >> is an opCall call. Otherwise, it's a struct literal.
> >
> > I haven't tried that in real code, so I can't be sure, but while it
> > may work for the compiler, it sounds a bit too much complex for the
> > person that later reads the code. Too many alternative possibilities
> > may make the code more complex to follow.
> >
> > To reduce such ambiguity (ambiguity for the person, not for the
> > compiler) may be to change the syntax of struct literals...
>
> I disagree, I think just the reverse. The S(args) syntax means that it's
> entirely up to the struct designer to say how it should work. The user
> needn't know or care, and the struct designer can change the design
> without affecting user code.
>
And why not "new S(args)" to call the constructor (which is natural so far) and "S(args)" to work as it does now?
More information about the Digitalmars-d-announce
mailing list