`bytes` as alias for `list<u8>`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, wasm
Direzione di ricerca
Start by reading the new JS explainer in #686 and the issue’s discussion of list at the ABI level. Determine whether bytes should remain an alias there, then establish the accepted JavaScript mappings for list and bytes, including parameter behavior and Uint8Array handling.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
While reading through the new JS explainer in #686, I found myself going back and forth on whether to use typed arrays for list<num>. For list<u8> it seems fairly natural to map that to Uint8Array, but less so for other number types. Like, it's probably quite a footgun to return Int32Array for list<s32>, since most JS devs don't use typed arrays very often, and typed arrays look juuuuuust enough like normal arrays to do some really surprising things:
> new Int32Array([1, 2, 3]).map(n => `item ${n}`)
Int32Array [0, 0, 0]
Surely no one would complain about this.
But that got me thinking - the main difference seems to be that sometimes you want a list of numbers, using whatever list type is idiomatic, but sometimes you just want a blob of bytes. Sure, you can have Int32Array and Float64Array and so on, but at least 95% of the time in JS you just want Array. And after further reflection, I think this is true of other languages too! In C++, do you really want a std::vector<uint8_t>, or would you maybe prefer std::string or some other kind of slice type? In Java, do you want List<Byte> or byte[]? In Python, do you want list or bytes? In Rust, do you want Vec<u8> or &[u8]?
(This is not true for some languages, e.g. Go would always do []byte, but that's fine, the distinction doesn't have to be meaningful in every language.)
So, purely as a hint to bindings generators, I think there is probably some value in having a bytes type that is in every way just an alias for list<u8>. Certainly there is no need for it to be different at the ABI level.
If accepted, I would suggest the following for the JS mapping:
list<T>is returned as a JS array, and as a param only accepts a JS array (...or iterable? idk)bytesis returned as aUint8Array, and a param accepts anything the TypedArray constructor would (which encompasses all typed arrays, ArrayBuffers, and JS iterables)
- Lingua principale
- WebAssembly
- Stelle
- 1.4k
- Fork
- 132
- Merge medio
- 2g 23h
- PR unite (30g)
- 11
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di WebAssembly/component-model
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
WebAssembly/component-model#609 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Specifying lockdown behaviorAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
WebAssembly/component-model#727 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
WebAssembly/component-model#724 · 10 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
WebAssembly/component-model#695 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
WebAssembly/component-model#694 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di WebAssembly/component-model
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
SciML/Evolutionary.jl#182 ·
I maintainer di solito rispondono entro 1 giorno
-
Missing GLM modelsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
simonw/llm-mistral#43 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
rossoctl/context-guru#346 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
prime-radiant-inc/evener#2883 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
GoogleChromeLabs/project-sesame#216 ·
I maintainer di solito rispondono entro 12 giorni