what is the state of property-functions?

Adam D. Ruppe destructionator at gmail.com
Sat Feb 6 20:34:52 UTC 2021


On Saturday, 6 February 2021 at 20:21:16 UTC, Martin wrote:
> What is the state of property-functions?

It works ok for basic cases. Broken cases include:

foo.prop += 5 // you must do foo = foo + 5

foo.callable_prop(); // if it returns a callable, you prolly have 
to use double parens to actually call it, foo.callable_prop()()

&foo.prop // gives a delegate, unless it returned ref



Otherwise it really isn't too bad just you don't need the 
@property annotation itself, all it actually affects is 
typeof(foo.prop) and like override mangling.

So if you never used @property you probably wouldn't care too 
much.

If you do use it, be aware of the three potential gotchas above 
and be advised if you do some kind of hack to work around this, 
you thing might break some time around the year 2245 at the 
current rate of progress. Maybe the crew of the starship 
Enterprise will have their code break when @property's 
"definition is more certain and implementation more mature" but 
you probably shouldn't worry too much about it.


More information about the Digitalmars-d mailing list