On 11/10/11 5:17 PM, Kisub Song wrote: > Even though the original ECMAScript does not support the type > restriction of array, I can implement arrays that allow values of > specific type as their elements. in case of platform array object. > > What I am wondering is that allowing only specific type value for an > array is right policy or not. > > If it is right policy, what should happen if user try to assign wrong > type value to an array? ... > var as = getTypeAArray(); // returns array of TypeA. > > var b = getTypeB(); // returns value of TypeB. > > as[0] = b; // What should happen in this situation? > // exception? or silently ignoring? The spec defines that to throw an exception, through step 2.3.5 of the platform array object [[DefineOwnProperty]] algorithm, which "converts" the JS value on the rhs of the assignment to the IDL type of the array's elements. http://dev.w3.org/2006/webapi/WebIDL/#platform-array-object-defineownpropertyReceived on Monday, 5 December 2011 23:44:44 UTC
This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC