Array Generics and null

Lars Hansen lhansen at adobe.com
Sun Mar 30 06:54:14 PDT 2008


> -----Original Message-----
> From: es4-discuss-bounces at mozilla.org 
> [mailto:es4-discuss-bounces at mozilla.org] On Behalf Of Brendan Eich
> Sent: 29. mars 2008 11:05
> To: Mike Shaver; es4-discuss
> Cc: Dean Edwards
> Subject: Re: Array Generics and null

> We would rather:
> 
> function topLevel(a,b,c) {
>    print(this, a, b, c);
> }
> topLevel(1,2,3);
> 
> print "undefined 1 2 3" than "[object global] 1 2 3".
> 
> This is incompatible, so it would happen only in some opt-in 
> version, or opt-in version + strict pragma enabled.
> 
> The issues are whether undefined or null should be the 
> default (undefined has won, AFAICT), 

The third option on the table is that the reference to 'this'
inside the body of topLevel simply throws an error.  This has
both less and more utility: the function can't discover if it
was called as a function or as a method; but functions that
simply assume they were called as methods will fail earlier.

--lars



More information about the Es4-discuss mailing list