On Fri, 29 Jan 2010 13:52:25 -0500, Andrei Alexandrescu <seewebsiteforem...@erdani.org> wrote:

Michel Fortin wrote:
My definition is that a property gives access to an aspect of an object and doesn't modify it (the getter is essentially logical-const).

Ok this makes sense. So something is a property if fetching it doesn't mess up the parent object. (Maybe properties should be pure even.)

No, because pure implies that the object must be immutable. They should be inout (if indeed they do not modify the object).

But you have some problems there. Whether it logically modifies the object or not (I hate to use it, but byLine.front as proposed would have to not be inout) is subject to interpretation. I think it should not be a hard requirement, and at best should be expected to possibly mutate private state.

The lingering question is whether you can later use the fetched property to operate change in the parent object. I guess that it's reasonable to leave that up to the person defining the object and its property.

It isn't any different than using a field to modify the parent's state. Not modifying the parent's state is simply not in the charter for properties. It's too strict, and doesn't follow the abilities of that which it is modeled after.

That being said, I agree with Pelle that actions invoked without parens are darn attractive.

To each his own.  I find them unclean and ambiguous.

-Steve

Reply via email to