DMD 1.035 and 2.019 releases
Pablo Ripolles
in-call at gmx.net
Thu Sep 4 03:13:37 PDT 2008
little typo:
writefln("f(%1$s) = %2$%", x, y); ---> writefln("f(%1$s) = %2$s", x, y);
it doesn't compile anyway!
Walter, don't you think that the ctor overloading should be on "static opCall" better than *any* opCall?
Pablo Ripolles Wrote:
> Sorry, but this is already somewhere else, I don't know why but I get my responses out of thread...
>
> Walter Bright Wrote:
>
> > Jarrett Billingsley wrote:
> > > Speaking of syntactical ambiguity, the expression
> > >
> > > S(1, 2, 3)
> > >
> > > can, right now, have one of three meanings:
> > >
> > > 1. A struct literal for struct S
> > > 2. A call to S's static opCall
> > > 3. An instantiation of S and a call to its ctor
> > >
> > > Even if opCall goes away, we'll still be left with the ambiguity of
> > > struct literal vs. ctor. I'd really, really like to hear Walter's view
> > > on this but he has responded neither to the thread I posted on
> > > digitalmars.D nor the bugzilla ticket
> > > (http://d.puremagic.com/issues/show_bug.cgi?id=2170).
> >
> > 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.
>
> shouldn't this be so only for the static opCall's?
>
> shouldn't this be possible?
>
>
> ///////////////////////////////////////////////////////
>
> import std.stdio;
>
>
> struct Parabola
> {
> float a_;
>
> this(float a)
> {
> a_ = a;
> }
>
> float opCall(float x)
> {
> return a_ * x*x;
> }
> }
>
>
> void main()
> {
> Parabola f;
> float x, y;
>
> f = Parabola(1.0);
> x = 2.0;
> y = f(x);
>
> writefln("f(%1$s) = %2$%", x, y);
> }
>
>
> ///////////////////////////////////////////////////////
>
>
> Thanks!
>
> >
> > Otherwise, it's a struct literal.
>
More information about the Digitalmars-d-announce
mailing list