dslomov / typed-objects-es7

ES7 typed objects spec draft
126 stars 7 forks source link

Add redimension method for arrays #6

Open nikomatsakis opened 10 years ago

nikomatsakis commented 10 years ago

Arrays need a redimension method that lets you redistribute their elements over any number of dimensions. As implemented in SpiderMonkey, this method lets you:

  1. Convert a non-array type T into an array type T([1])+ -- i.e., any number of dimensions, as long as they all have length 1.
  2. Convert an array type T[...] into an array type U[...] as long as T and U are equivalent.

Note that this second test is slightly wrong: we should require that T === U to preserve aliasing guarantees (we could do T === U || (T.isTransparent() && U.isTransparent() && T.equivalent(U)), but why? you could always cast the buffer).