@property - take it behind the woodshed and shoot it?

Jonathan M Davis jmdavisProg at gmx.com
Thu Jan 24 11:14:46 PST 2013


On Thursday, January 24, 2013 14:43:33 Adam D. Ruppe wrote:
> No, god no. This would break code AGAIN and still not fix the
> problems, instead introducing new ones!
> 
> I think any property proposal that talks about parenthesis in the
> definition is wrong. With a good definition, the existing type
> system will handle the parenthesis.
> 
> @property int foo() { return 10; }
> 
> foo(); // the correct error is "type int is not callable"
> 
> This is the key point:
> 
> A property is NOT a function as far as user code is concerned.
> That's just an implementation detail.
> 
> As far as user code is concerned, a property IS its return value.
> 
> 
> If you implement that, leaving all the other rules in the
> language exactly the same, we'll actually fix some problems
> without breaking the overwhelming bulk of existing code.
> 
> 
> Fixing the rest of the problems is then about getting op*Assign
> to work right.
> 
> 
> 
> Functions not marked @property should NOT change AT ALL from what
> we have now. I am against removing the existing optional
> parenthesis rule, and I am against removing the @property
> decoration.
> 
> Fix it this time, don't break it in a different place.

Yes. I think that it's fairly clear that we need to do something like this. 
Getting rid of @property is throwing out the baby with the bathwater. Not 
having it is a complete mess. And plenty of corner cases have been shown just 
in this thread which show how not having @property causes problems, completely 
aside from the issue of whether you should be allowed to call functions 
without parens.

Personally, I'd love strict property enforcement, but I think that it's clear 
at this point that that's not going to fly. However, a solution like this which 
is effectively weak property enforcement (parens illegal on @property functions 
but optional for normal functions) fixes the worst technical problems caused by 
the lack of @property, and this particular proposal seems like a solid way to 
go about it.

- Jonathan M Davis


More information about the Digitalmars-d mailing list