WebAssembly / esm-integration

ECMAScript module integration
https://webassembly.github.io/esm-integration/js-api/index.html#esm-integration
Other
378 stars 32 forks source link

Nit: What should we use the term "live binding" for? #19

Closed littledan closed 5 years ago

littledan commented 6 years ago

I originally thought "live binding" referred to a mutable variable storage, which could be exported, and then overwriting the variable on one end would affect the live binding on the other end.

The README in this repository, and under #13, seems to use "live binding" to mean something else: when wasm exports something (e.g., a Global, Memory, or Table) which is somehow mutable, then the binding is "live" in the sense that, when that object is mutated, it's reflected in the exported version. This usage was initially surprising to me; I would've thought of this as a kind of snapshot (just a shallow one, of a mutable object)

I'd suggest that, in this proposal, we either clarify that we're using this broader sense of "live binding" (could be just a couple sentences), or avoid the term.

xtuc commented 6 years ago

I think that a mutable Object is a better term, whereas live binding would implit a direct memory access?

The WebAssembly spec doesn't mention "live binding", we should avoid introducing it here.

sendilkumarn commented 6 years ago

But specifying mutable Object will give an impression of an object is mutable in two ways (both via JS and WASM). I think it is a thin line here

xtuc commented 6 years ago

Well, for WebAssembly.Memory or WebAssembly.Global (mutable) that's how they work.

sendilkumarn commented 6 years ago

yeah, I agree, but that does not include everything right?

littledan commented 6 years ago

OK, sounds like we should avoid calling exported functions mutable objects. Anything else?

sendilkumarn commented 6 years ago

I think yes. since WebAssembly.Tables are mutable in JS world.

xtuc commented 6 years ago

This thing is that from a JS perceptive (unless it's readonly) a WebAssembly func (HostFunc) is a mutable object, right? You can perform mutation; add props etc.

I think we should just avoid the term "live binding" and call the communication surface: API.

Otherwise it seems to me that location.href should be called "live binding" too.

littledan commented 6 years ago

Yes, it's true, and the Wasm/JS API guarantees that the host functions are shared when being re-exported multiple times.

sendilkumarn commented 6 years ago

@xtuc does it means that I can override the HostFunc in JS with something else and it will be updated is it?

sendilkumarn commented 6 years ago

that the host functions are shared

Yeah, they are shared. Are they mutable?

littledan commented 6 years ago

Yes, they are ordinary mutable JS objects.