@property - take it behind the woodshed and shoot it?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Jan 28 10:08:39 PST 2013


On Mon, Jan 28, 2013 at 07:04:21PM +0100, Dicebot wrote:
> On Monday, 28 January 2013 at 17:52:45 UTC, TommiT wrote:
> >If you think my example of {start_time, end_time, duration}
> >represents proper use of properties, then I don't see why you
> >oppose array.length. To me it seems like the same thing. Array has
> >some length, and you can change it by changing its length
> >property. T represents a certain time range, and you can change it
> >by changing any of its three properties {start_time, end_time,
> >duration} which describe that time range.
> 
> T changes its inner encapsulated states. Period. It is no different
> that properties that calculate result on the fly, like range.empty
> (which is good property usage).
> 
> Array.length allocates. Takes from some global resources, takes some
> considerable time, calls some global allocating function.
> 
> For me it is a crucial difference that pushes symbol to the world of
> functions.

In the dinosaur age of Motorola 6502 processors, writing certain values
to certain "magic" memory addresses triggers side-effects like switching
the console into graphics mode. One could argue this is bad design, but
it *is* a precedent for side-effects when assigning values to what can
be thought of as "just a variable". By comparison, array.length is
pretty tame (no visible side-effects except that the array becomes
longer).


T

-- 
Life is too short to run proprietary software. -- Bdale Garbee


More information about the Digitalmars-d mailing list