Web IDL Garden Hose

David-Sarah Hopwood david-sarah at jacaranda.org
Sun Sep 27 14:33:43 PDT 2009

Brendan Eich wrote:
> On Sep 27, 2009, at 10:41 AM, David-Sarah Hopwood wrote:
>> Brendan Eich wrote:
>>> On Sep 26, 2009, at 6:08 PM, Maciej Stachowiak wrote:
>>>> This may provide a way to implement some of these behaviors in pure
>>>> ECMAScript. The current proposal does allow [[Construct]] without
>>>> [[Call]], but not [[Call]] and [[Construct]] that both exist but with
>>>> different behavior.
>>> Date needs the latter.
>> That can already be done in ES5. As I've previously suggested:
>>  function Date(yearOrValue, month, date, hours, minutes, seconds, ms) {
>>    "use strict";
>>    if (this === undefined) {
>>      return TimeToString(CurrentTime());
>>    }
>>    // constructor behaviour
>>    ...
>>  }
> Of course, a variation on "the idiom".
> This is similar to what many implementations do too, rather than the
> implementation providing analogues of [[Call]] and [[Construct]]
> internal method on a non-function Date object. It works for Boolean,
> Number, String, and RegExp too.
> But it is just a bit unsightly!

<shrug>. It's compatibility guff. Unsightliness in implementation code
is better than adding a language mechanism just to handle a small and
fixed (for all time, hopefully) set of special cases.

(This has probably drifted off-topic for public-{webapps,html}@w3.org,
sorry about that.)

David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com

More information about the es-discuss mailing list