On Sunday, July 15, 2012 22:47:41 Timon Gehr wrote: > On 07/15/2012 09:41 PM, Jonathan M Davis wrote: > > On Sunday, July 15, 2012 11:56:57 Jonathan M Davis wrote: > >>> What is enforced here? Why would it matter if anything is 'enforced'? > >> > >> If you marked it as a property, then it's supposed to be abstracting a > >> variable and should be treated as one, just like if it's a normal > >> function, > >> it should be invoked as a function, just like ++ shouldn't suddenly do > >> --, > >> and / shouldn't *. > > > > And on a purely objective note, if you don't have property enforcement, > > you > > can't turn a property function into a variable, because even though it's > > supposed to be used as one, you can't guarantee that everyone's using it > > that way, and if they're using it as a function, changing the property > > into a variable will break their code. And part of the point of > > properties is to be able to switch between variables and property > > functions depending on whether additional protections or calculations or > > whatnot are required for that variable/property. Property enforcement is > > required in order to allow that. > > > > - Jonathan M Davis > > No it is not, assuming that property enforcement is supposed to mean > that function 'foo' cannot be called like 'foo' if it is not annotated > @property. > > There is no objective argument for banning this, except that the syntax > would be made free for alternative use. > > @property means: always implicitly call if it can be called without > arguments. If it cannot, disallow calls that are not of the form fun = > argument; (After the op= operators have been properly rewritten.) > > And that is completely sufficient for transparently switching between > variable/property. Stuff that is *not* annotated @property has no > relevance.
There are two levels to enforcement. Neither exist without -property. The absolutely minimal level is that anything marked with @property must be used as a property. Without this, you can't swap out a property function for a variable without breaking code. The second level - i.e. strict property enforcement - also requires that non- property functions be called as functions. -property is supposed to be doing strict property enforcement, but it's pretty buggy at the moment, so you can't really use it to guarantee much yet. - Jonathan m Davis
