Re: [heycam/webidl] String marshaling/interop for wasm and asm.js scenarios (#716)

> Naming nit: if this happens, should we call it a `ProbableUTF8Array` or some such for consistency with existing views?

UTF8Array would make sense. If it's 'probable' I think that indicates severe neglect on the part of the caller, unless probable just indicates that it's possible the string goes away after it was constructed (because of manual allocation). The downside to calling it array is that it implies the [] operator, but maybe that operator is easy to implement.

Making it useful as a StringView just implies that the array has .toString, which I guess has a history of doing roughly what you want on other array types. Then .toString can have a runtime-level fast path, or an IDL-level one (so it becomes fast to pass a UTF8Array to IDL APIs). Maybe a UTF16Array also comes with the bargain.

For managing lifetime (i.e. telling the runtime that you freed the underlying memory) maybe you just detach the view? Detached arrays already have well-defined behavior, iirc

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/716#issuecomment-485876429

Received on Tuesday, 23 April 2019 16:26:12 UTC