Fixing const arrays

Tobias Pankrath tobias at pankrath.net
Sun Dec 11 05:54:27 PST 2011


> 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.


More information about the Digitalmars-d mailing list