Fixing const arrays

Jonathan M Davis jmdavisProg at gmx.com
Sun Dec 11 13:24:45 PST 2011


On Sunday, December 11, 2011 14:54:27 Tobias Pankrath wrote:
> > Specifically:
> > 
> > "Properties should behave as if they are fields; if the method cannot,
> > it should not be changed to a property.
> > Methods are better than properties in the following situations:
> > 
> > - Calling the method two times in succession creates different results.
> > - The method performs a time-consuming operation. The method is
> > perceivably slower than the time that is required to set or get the
> > value of a field."
> > 
> > Since both of these can be true for all but the most trivial kinds of
> > ranges (e.g. file-system-related enumerators/ranges would very likely
> > need to re-open a handle to a directory in order to traverse it, which
> > is both relatively time-consuming AND returns a different result every
> > time, and could even unexpectedly fail due to permission/connectivity
> > issues), I don't think it makes sense for save() to be a @property.
> 
> I agree.

It was debated some time ago, and it ended up being a property. The fact that 
save is an action verb and not a noun automatically disqualifies it as a 
property IMHO, but it was made into a property, and we're pretty much stuck 
with it at some point. As far as what the function does, I don't think that 
it's a problem that it's a property, but it's not named like a property, so 
the situation with regards to save is not ideal, but it's too late now.

- Jonathan M Davis


More information about the Digitalmars-d mailing list