You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm confused, how would this not work out of the box? If it's actually a proper instance of ArrayBuffer, then it'd be detachable; if it's not detachable, then it's not a proper instance of ArrayBuffer.
I'm confused, how would this not work out of the box? If it's actually a proper instance of ArrayBuffer, then it'd be detachable; if it's not detachable, then it's not a proper instance of ArrayBuffer.
I mean, if there is a case that the host wants to reject the AB being detachable. this is like HostEnsureCanAddPrivateElement that limits the ability of adding a private field to a host object.
I'm confused, how would this not work out of the box? If it's actually a proper instance of ArrayBuffer, then it'd be detachable; if it's not detachable, then it's not a proper instance of ArrayBuffer.
Why would we want to consider a host hook when no use case for that has presented itself?
Host buffers can already be non-detachable/transferable via [[ArrayBufferDetachKey]], e.g. WebAssembly.Memory can't be transfered/detached (except via other WebAssembly methods, e.g. mem.grow does detach the previous buffer):
constmem=newWebAssembly.Memory({initial: 1});// Throws a TypeErrorconstnewBuffer=mem.buffer.transfer();constoldBuffer=mem.buffer;mem.grow(1);// Now detachedoldBuffer.detached;// trueoldBuffer===mem.buffer;// falseconstmem=newWebAssembly.Memory({initial: 1,maximum: 1});// Not detachable by any meansmem.buffer;
I don't see that this proposal needs anything special, if a host buffer can't be transfered to an immutable buffer then they can just set [[ArrayBufferDetachKey]] and provide a separate API.
Activity
ljharb commentedon Dec 24, 2024
I'm confused, how would this not work out of the box? If it's actually a proper instance of ArrayBuffer, then it'd be detachable; if it's not detachable, then it's not a proper instance of ArrayBuffer.
Jack-Works commentedon Dec 25, 2024
I mean, if there is a case that the host wants to reject the AB being detachable. this is like
HostEnsureCanAddPrivateElementthat limits the ability of adding a private field to a host object.ljharb commentedon Dec 25, 2024
Why would we want to consider a host hook when no use case for that has presented itself?
Jamesernator commentedon Dec 26, 2024
Host buffers can already be non-detachable/transferable via
[[ArrayBufferDetachKey]], e.g.WebAssembly.Memorycan't be transfered/detached (except via otherWebAssemblymethods, e.g.mem.growdoes detach the previous buffer):I don't see that this proposal needs anything special, if a host buffer can't be transfered to an immutable buffer then they can just set
[[ArrayBufferDetachKey]]and provide a separate API.Jack-Works commentedon Dec 26, 2024
Thank you! This is first time I learn
ArrayBufferDetachKey