-
Notifications
You must be signed in to change notification settings - Fork 57
Why is ByteString a string? #131
Comments
That's a good question. So as background, I think it's important to have wasm-to-Web-IDL calls be mostly equivalent to wasm-to-JS-to-Web-IDL calls, where the interposed JS simply forwards arguments/results back and forth to Web IDL -- that way, if a built-in Web IDL function is polyfilled/virtualized by JS, it doesn't suddenly break wasm. While Thinking about it some more, it seems like there are three options:
I think 1 would be ideal, and perhaps it would be beneficial for other reasons. WDYT? |
I see, if it has to be mostly equivalent it will have to be a string, as that is what it is in JavaScript. I suppose IDL could accept a Uint8Array on the coercion side, but it couldn't start returning Uint8Array where it previously returned a string. (Unless there is some magic that would enable this for Wasm callers only?) (I was mainly suggesting this because I think it makes sense for IDL to convert this string to a byte sequence for specifications and to allow specifications to return a byte sequence to something that wants a ByteString. Whether this makes sense to copy in implementations would vary, but for HTTP header related cases it definitely would.) |
Ah, good point about the return case, I forgot to consider that. Because of the "allow interposed JS" goal I mentioned above, I don't think we can use "if the caller is wasm ..." logic. However, I think we could say that |
It seems nicer if it could map to a byte sequence, or is that not something that exists? (Same for
ArrayBuffer
I suppose.)The text was updated successfully, but these errors were encountered: