Stream: wit-bindgen

Topic: ✔ No more self references in exports?


view this post on Zulip bachrc (Feb 21 2023 at 01:28):

Hello ! I’m learning everything webassembly for 3 days, my head’s gonna explode but I think I’m not that far to succeed! I think so.

When, from a guest, you are generating from a wit. You make your struct, your methods implementing the generated interface… but why are there not self references anymore ? This would be so helpful to create wasm programs which are more than a « call and return »

view this post on Zulip bachrc (Feb 21 2023 at 11:58):

Well, I struggled to find any documentation, but it seems that what I need is the resource element. I'm gonna try this out.

view this post on Zulip Ramon Klass (Feb 21 2023 at 12:11):

Resources are not implemented in the current iteration, they are planned to be added again for the next major version

since each wasm component has entirely separate memory, I would suggest to use global state inside the component if there is data you want to persist between calls of component functions, in Rust that would be something like a OnceCell or lazy_static

view this post on Zulip bachrc (Feb 21 2023 at 12:21):

Not implemented? How can this issue be resolved then? https://github.com/bytecodealliance/wit-bindgen/issues/178

I'm looking into using resources with the following .wit file: resource aggregate { static new: function(id: string) -> aggregate apply-events: function(event: list<list<u8>>) } ...

view this post on Zulip Ramon Klass (Feb 21 2023 at 12:23):

in the current iteration<

the previous wit files were for wasi commands, which implemented wasi_snapshot_preview1. Right now we are almost at preview2, which is basing everything on the component model, but the component model does not yet have Resources

you can use an old version of wasmtime if you want to play with the deprecated wasi format instead of the component model or you can wait a few more weeks to play witht he new version

view this post on Zulip bachrc (Feb 21 2023 at 12:25):

Okay I see! Thanks a lot for your answer and time, have a great day :)

view this post on Zulip Notification Bot (Feb 21 2023 at 12:25):

bachrc has marked this topic as resolved.

view this post on Zulip bachrc (Feb 21 2023 at 12:33):

Will the resource be something handled by the component model at some time, or is it again a design?

view this post on Zulip Ramon Klass (Feb 21 2023 at 12:41):

as far as I'm aware they will absolutely be in the final specification, but I don't know specifics what is blocking what currently

view this post on Zulip bachrc (Feb 21 2023 at 13:17):

Okay! Thanks a lot :)


Last updated: Nov 22 2024 at 16:03 UTC