On Aug 27, 2013, at 3:49 PM, David Herman wrote:
> On Aug 27, 2013, at 9:47 AM, Filip Pizlo <[email protected]> wrote:
>
>> I do. Placing named properties on arrays makes sense. Consider a matrix
>> implemented as a Float32Array, with named properties telling you the numRows
>> and numCols. Just one example.
>
> There are of course other ways to achieve this that don't involve patching
> the array object, such as building a data abstraction for matrices that has-a
> Float32Array, or creating a new array type with additional methods:
>
> var Matrix = new ArrayType(float32);
> Matrix.prototype.numRows = function() { ... }
> // or
> Object.defineProperty(Matrix.prototype, { get: function() { ... }, ... });
or even better:
class Matrix extends Float32Array {
get numRows() {...}
...
}
although "Matrix" may be a bad example...
Subclasses of Typed Arrays get their own prototype that can add or over-ride
inherited methods. The instances of the subclass are still non-extensible
according to the current spec. draft.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss