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

TommiT tommitissari at hotmail.com
Mon Jan 28 10:31:48 PST 2013


On Monday, 28 January 2013 at 18:04:22 UTC, Dicebot wrote:
> 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.

The question "what is or should be a property?" is a question of 
semantics. I don't see what performance or those implementation 
details you mentioned have to do with semantics.

What if our container type wasn't a dynamic array? Let's say it's 
a pseudo container that pretends to be a vector of consecutive 
int values, but in reality it just has two integers which denote 
the beginning and the end of the range. Now changing the length 
property of that container takes constant time (it just sets the 
end value anew).


More information about the Digitalmars-d mailing list