On Jun 28, 2006, at 10:32 AM, P T Withington wrote:

I'm confused.  How can this work:  `this.timerList[d]` (where d is a delegate, hence an object?)


Hrm? It certainly does work. You can use any object as a key in _javascript_, no?


I am pretty sure Object keys are strings, although I can't find where it says that in ECMA.  When you use something other than a string as a key, the value is converted by String(key), so for a general Object it will call key.toString().  So, you _could_ make this work by giving delegates a toString method that guaranteed to generate unique strings.  (I assumed this is why you are testing for the return value from setInterval to _not_ be an object?)


Thanks for the education. I'm rethinking my approach, somewhat ashamed that apparently I didn't sufficiently test multiple timers before submitting my changeset.

Replying to the parenthetical: I'm testing for not-an-object to ensure that I can differentiate between the single-timer case and the multiple-timer case. In the single-timer case, I store the ID by itself to avoid an array allocation. If the ID is itself an object, though, I can't tell it from an array. (Oh, and of course I should be using "instanceof Array" in this case, so the ID just can't be an Array. When using 'typeof' I didn't think I could differentiate between Array and Object, but with instanceof I can.)

jim
_______________________________________________
Laszlo-dev mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-dev

Reply via email to