ES4 draft: Vector

Brendan Eich brendan at
Wed Mar 5 18:56:13 PST 2008

On Mar 5, 2008, at 5:58 PM, Jon Zeppieri wrote:

> On 3/5/08, Lars Hansen <lhansen at> wrote:
>> Note, the Vector class called as a function does not create a new
>>  vector if its input is a vector.  The prose is wrong in the draft,
>>  but the code is right.
>>  There probably should be copy() method on the Vector class.
> It's identical to a slice() with no specified parameters.

Thanks for pointing this out. Also equivalent to v.concat() for  
vector v. True of all array-likes.

>> What's the nice invariant?
> An actually fixed length.  The proposed 'fixed' field is a debugging
> aid.  A read-only version, on the other hand, is a guarantee that
> holds even if you hand your vector off to code you didn't write and
> don't trust.

What I have wanted in the past is a variable length vector whose  
length I can freeze at some point. Akin to sealing an object  
completely against mutation, after mutating it into good shape during  
its early lifetime.

>>  It may be that a set-but-not-reset property is an alternative,
>>  or that the length must be provided to the constructor and that
>>  it is fixed after that.  Both seem less flexible than the current
>>  design and I'm not sure what the benefits would really be (apart
>>  from safety against "hostile" code, but then you wouldn't be
>>  working in ECMAScript).
> Mingling with others' code is something that already happens on the
> web; consider how (legitimate) services get around the cross-site
> restrictions browsers implement.  I can't imagine security in ES is
> going to get less important.

Lars's parenthetical aside I interpreted as trolling ;-).

I don't believe in a silver bullet for mashup security. On the other  
hand, for programming-in-the-large sanity if not security, fixed  
length vectors, fixtures in classes, nominal type relations based on  
name not structure, namespaces and immutable name bindings -- all of  
these integrity features help.


More information about the Es4-discuss mailing list