[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Please make the ArrayBufferView constructor visible




I don't think there is one, other than just adding more stuff to the global namespace. I don't think that's that big of a problem. I suspect the reason why NoInterfaceObject got added is that there wasn't much of a reason to have it exposed... likely people didn't think of instanceof checks :)


    - Vlad

On 12/9/2012 1:36 PM, andre v wrote:
What is the downside of having ArrayBufferView exposed? Too much stuff
in the global namespace? People struggling with trying to create new
ArrayBufferViews?

On Sun, Dec 9, 2012 at 10:20 AM, Ben Vanik <benvanik@google.com> wrote:
Agreed! Having a giant if-chain of types is nasty and slow - every time I
have to do this I cringe.


On Saturday, December 8, 2012, Victor Costan wrote:

Dear WebGL working group,

ArrayBufferView is currently marked as [NoInterfaceObject] in the
Typed Array IDL.
https://www.khronos.org/registry/typedarray/specs/latest/typedarray.idl

Higher-level abstractions need to be able to write "x instanceof
ArrayBufferView". Currently, implementors have to do horrible things
to work around the lack of an ArrayBufferView name. For example,
Google Chrome's authors recommend this hack to obtain a reference to
ArrayBufferView.

var ArrayBufferView = (new Uint8Array(0)).__proto__.__proto__.constructor;
Source: https://code.google.com/p/chromium/issues/detail?id=60449

Please make ArrayBufferView available in the global namespace, so
instanceof checks can work. I would suggest that the constructor
should throw a TypeError exception if called, to be consistent with
the current behavior of the above workaround. I haven't thought too
much about that though. Also, given the above workaround, I don't
think there is any security implication in making ArrayBufferView
available in the global namespace.

In case you're looking for a real-life application: I am the author of
dropbox.js, a JavaScript library that serves as a client to the
Dropbox API. I want to make it easy to my users to write files, so I
let them pass anything that contains data -- Strings, Files, Blobs,
ArrayBuffers, ArrayBufferViews. Not having ArrayBufferView available
means I'll have to use the horrible hack suggested by the Chrome
authors.

Please consider making this change, so future Web developers can have
a better life!

Thank you very much,
     Victor Costan

Victor Costan | victor@costan.us | www.costan.us | +1 (646) 434-8887
Massachusetts Institute of Technology
Department of Electrical Engineering and Computer Science, B.S. '07,
M.Eng '08, Ph.D. '14
Sloan School of Management, B.S. '07

-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------

-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------



-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------