On Oct 3, 2008, at 12:03 AM, Geoffrey Garen wrote:

// should be implemented by Window objects
interface WindowTimer {
     Timer startTimer(in double delayInSeconds, in boolean repeating,
in TimerHandler handler);
}

How about a "Timer" constructor function instead?

Pros:

* Fits the object-oriented programming model of "new Image", "new XMLHttpRequest", etc.

* Enables use of object-oriented features like instanceof, the .constructor property, and prototype-based extensions to timer objects.

* Distinguishes itself better from the old setTimeout / setInterval functions.

In general, the DOM does not depend on a constructor as the only way to create a kind of object, since it is nominally language-agnostic. In fact, for most things it doesn't provide a constructor invokable as such at all; you listed some of the few exceptions.

In addition, "new Timer(...)" does not as clearly express the fact that the timer is not only created but started right away. So I don't think a constructor would be good as the sole interface for starting a timer.

readonly attribute double timeElapsed; // time in seconds since
"elapsedTime" reads better to me, since it makes "elapsed" definitely an adjective, and not a verb.

Good suggestion.

Regards,
Maciej

Reply via email to