While we're lynching features, how bout' them omittable parens?

Steven Schveighoffer schveiguy at yahoo.com
Tue May 19 09:24:19 PDT 2009


On Tue, 19 May 2009 10:12:13 -0400, Leandro Lucarella <llucax at gmail.com>  
wrote:

> Steven Schveighoffer, el 19 de mayo a las 09:54 me escribiste:
>> >So for me, properties are way more than just syntax sugar.
>>
>> AFAIK, this is not enforced by the compiler...
>>
>> I write C# properties that have side effects.
>
> Well, in D2 it would make sense to make mandatory that properties are  
> pure
> =)
>
> I think the actual syntax is really nice and simple, the only thing
> missing is a way to declare that you expect some function to be
> a property.
>
> Something like this should be enough for me:
>
> class C
> {
> 	int no_prop() { return 1; }
> 	property int prop() { return 2; }
> }
>
> C c = new C;
> int x = c.no_prop; // error
> x = x.prop; // ok
>
> "property" should imply "pure".

As Jarrett said, a pure setter is impossible.  But, having pure getters  
even seems like an unnecessary limitation.

Having setting and getting grouped together would be nice to me (for  
documentation/lookup reasons), but not necessary.  As long as there's a  
way to denote "property" versus "function", the scheme works.

-Steve



More information about the Digitalmars-d mailing list