CTFE can't replace @properties

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Oct 8 20:07:01 UTC 2020


On Thu, Oct 08, 2020 at 07:47:49PM +0000, 12345swordy via Digitalmars-d wrote:
> On Thursday, 8 October 2020 at 19:45:15 UTC, H. S. Teoh wrote:
> > On Thu, Oct 08, 2020 at 04:47:07PM +0000, 12345swordy via Digitalmars-d
> > wrote:
[...]
> > > int _x;
> > > public
> > > int x () { return _x; }
> > > int x (int x) { this._x = x; }
> > > 
> > > x += 2; // you can't do this.
> > > x++ //nor this.
> > 
> > Operator overloading is only supported by the opXxx member
> > functions.  This is by design.  But I don't understand what this has
> > to do with CTFE?
[...]
> It turns out that it has nothing to do with the CTFE. It simply a
> limitation that @propertiy is supposed to address.

Ah, now I understand.

Yeah, @property is poorly-implemented, and generally a mess beyond the
most rudimentary of use cases. I usually don't bother with it except
where I absolutely have to.

Though if you really care about it, filing an enhancement request might
be a way of documenting this particular use case, in case we ever
revisit this feature again.


T

-- 
Guns don't kill people. Bullets do.


More information about the Digitalmars-d mailing list