ES4 draft: Vector

Eylon Stroh estroh at adobe.com
Fri Mar 7 12:22:03 PST 2008


<< FIXME   Need to check a detail of the type system, namely whether
Vector.<T> is a subtype of Vector.<U> if T is a subtype of U and U is
not *. >>

It shouldn't be.  Consider Bar <: Foo, Baz <: Foo:

let baz:Vector.<Baz> = new Vector.<Baz>();
let foo:Vector.<Foo> = baz; // allowed if Vector.<Baz> is considered a
subtype of Vector.<Foo>
foo.add(new Bar());
let bazItem:Baz = baz.get(0); // type error!


Other comments:

push() is missing "length++;"

sort() is missing "return this;"

I think that the first for loop in unshift() should read
    for ( let i=1 ; i <= oldlimit ; i++ )
        this[newlimit-i] = this[oldlimit-i];
also, "return newlength;" should be
    length = newlimit;
    return length;
assuming that the length setter only sets the length property, without
setting any default values (otherwise it would need to be moved up to
before the for loops).


-----Original Message-----
From: es4-discuss-bounces at mozilla.org
[mailto:es4-discuss-bounces at mozilla.org] On Behalf Of Lars Hansen
Sent: Monday, March 03, 2008 12:36 PM
To: es4-discuss at mozilla.org
Subject: ES4 draft: Vector

I enclose a slightly incomplete/rough draft for the Vector class.
Please comment.

--lars



More information about the Es4-discuss mailing list