Stream: wit-bindgen

Topic: Class or struct declarations?


view this post on Zulip Gordon Smith (Jan 14 2023 at 06:46):

Are there any examples of how to declare a class in wit?

view this post on Zulip Gordon Smith (Jan 14 2023 at 07:00):

Looks like resource is what I am looking for?

Repository for design and specification of the Component Model - component-model/WIT.md at main · WebAssembly/component-model

view this post on Zulip Dan Gohman (Jan 14 2023 at 12:31):

Yes, a resource, if you want to pass around references to it. Though be aware that wit-bindgen doesn't support resources yet.

view this post on Zulip Dan Gohman (Jan 14 2023 at 12:31):

If you want to pass it by value instead of by reference, you can use a record.

view this post on Zulip Gordon Smith (Jan 15 2023 at 10:36):

Dan Gohman said:

Yes, a resource, if you want to pass around references to it. Though be aware that wit-bindgen doesn't support resources yet.

Thanks - I worked that out, looks like it was removed to be reimplemented once the spec has settled?

view this post on Zulip Gordon Smith (Jan 15 2023 at 10:36):

Dan Gohman said:

If you want to pass it by value instead of by reference, you can use a record.

I tried record but it doesn't support functions?

view this post on Zulip Ramon Klass (Jan 19 2023 at 15:45):

you can't serialize code generally, "by value" means you can only copy the data of the class, but not its methods, you would need to reimplement them on both host and guest side separately

view this post on Zulip Dan Gohman (Jan 19 2023 at 16:09):

Yes; instead of methods, you can have functions that take records as arguments.

view this post on Zulip Dan Gohman (Jan 19 2023 at 16:10):

Gordon Smith said:

Thanks - I worked that out, looks like it was removed to be reimplemented once the spec has settled?

Exactly.


Last updated: Oct 23 2024 at 20:03 UTC