Jason Orendorff jason.orendorff at
Wed Jun 2 00:52:21 PDT 2010

On Tue, Jun 1, 2010 at 6:29 PM, Sam Ruby <rubys at> wrote:
> On 06/01/2010 09:15 PM, Waldemar Horwat wrote:
>> I assume that the proposal is that:
>> const TA =
>> Array.newTypedArray(fixed_length,
>> Object.newStructType({x:"u32", y:"u32", z:"u32",
>> r:"u8", g:"u8", b:"u8", a:"u8"}));
>> let a = new TA(...);
>> b = a[i];
>> a[i].x += 1;
>> Now b.x also reflects the new value of a[i].x; i.e. b is an alias, not a
>> mutable copy.
> That's a valid choice, but one that can't be applied 100% consistently.  For
> example, wouldn't the following create a mutable copy?
>  a[0] = b;

The way this works in js-ctypes is that
  b = a[i];
causes b to be a struct object that aliases part of the array a; and
  a[0] = b;
copies an element from a[i] to a[0].

Neither creates a mutable copy in a new buffer.

> I'll also assume that all aliases will pin the entire array for the purposes
> of garbage collection.

This is how js-ctypes does it.

> I'll still maintain that the choice that ECMA 334 takes, namely
> that the assignment to b in the example above, makes a mutable
> copy is a valid choice.

I would expect
  a[0].x = 3;
to modify a[0], not a temporary copy of a[0]. How do you propose to
make that work in ES?


More information about the es-discuss mailing list