RFC
davidb
ta-nospam-zz at gmx.at
Thu May 24 04:09:21 PDT 2007
Gregor Kopp wrote:
>> Considering the Stack class:
>> I'm not quite sure about the use of "this.length" in the various
>> contexts, could someone please explain it to me?
>
> I used the length of my stack outside other programs. I wanted to know
> the elements nested inside my stack in other programs. My future plan is
> to write a small ide for the bf interpreter. So I have to rewrite the whole
> thing.
I meant this.size of course.
Note to self: first read, then post.
I mistook this.size for a kind of special (template) class property,
where it was just a function without the ()...
I don't know if the compiler optimizes it automatically,
but if you use e.g.
data[this.size - 1] = element;
it will call this.size() to determine data.length,
whereas
data[$-1] = element;
would just look it up from the array (no function call overhead).
david
More information about the Digitalmars-d-learn
mailing list