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

Ary Borenszweig ary at esperanto.org.ar
Tue May 19 10:35:05 PDT 2009


Leandro Lucarella 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".
> 

Well, maybe with "pure" I made a bad choice. The thing is that the 
instance doesn't seem to change from the outside, from the callee side, 
but from the inside it might cache something or lazily compute it. But 
yes, "pure" wouldn't work here.



More information about the Digitalmars-d mailing list