@property needed or not needed?

Jonathan M Davis jmdavisProg at gmx.com
Sun Nov 18 22:16:21 PST 2012


On Monday, November 19, 2012 07:02:03 Rob T wrote:
> So what's up with @property? Is it being depreciated for being
> redundant, or will it later be strictly enforced, or is it to be
> optionally enforced through a compiler switch?

It didn't used to be necessary, but there are ambiguities without it 
(particularly with regards to property functions which return delegates), and 
a number of people don't like the laxness of practically any function with a 
particular sort of signature being able to be used as a property function 
rather than it being part of the API. So, @property was introduced, but 
similar to override, it was decided that its enforcement would be phased in.
-property was introduced so that the compiler's enforcement of it could be 
sorted out (it's still very buggy) and so that everyone would have time to 
adjust their code so that it used @property correctly.

Now, how strict the enforcement will ultimately be is up for some debate. It 
needs to be the case that any @property function must be used as a property 
function in order to avoid the aforementioned ambiguities (so using parens 
will be illegal with @property functions), but there's quite a lot of 
dissension surrounding whether non-property functions should be callable as 
property functions (i.e. whether non- at property functions with the appropriate 
signature can be called without parens as is currently the case). Some of us 
consider it to be incredibly sloppy to allow it, whereas others find the idea 
of requiring parens to be extremely annoying (especially when dealing with 
UFCS). TDPL is somewhat ambiguous on the matter, and AFAIK, no official decision 
has been made.

- Jonathan M Davis


More information about the Digitalmars-d mailing list