Stream: general

Topic: Translating WebIDL to wit


view this post on Zulip Mendy Berger (Dec 27 2023 at 03:06):

As far as I can tell, wit resources can't have fields, only methods.
I'm working on translating some WebIDL files into wit, and I'm trying to figure out the best way to deal with this constraint.
Is the best way to just have setter and getter methods for each field?

view this post on Zulip Jeff Parsons (Dec 27 2023 at 08:43):

There's some discussion here around introducing "properties", but that's more about being able to generate more idiomatic bindings in various languages than doing anything fundamentally new — i.e. it would just be sugar over functions, the same way that resource methods are just functions.

I don't think it would be possible to have directly-accessed fields for resources, because their concrete representation is opaque to code holding a handle to them.

Most languages have either: language-level support for properties C#: string MyProperty { get; set; } JavaScript: get myProperty() JavaScript: set myProperty(value) or conventions on how to name pr...

view this post on Zulip Mendy Berger (Dec 28 2023 at 02:58):

Thanks @Jeff Parsons !

So I guess I'll just make my own getter/setters until this is properly specced.

view this post on Zulip Mendy Berger (Dec 31 2023 at 20:15):

Here's a list of conversions from WebIDL types to wit types. Some of them are obvious how to convert, but others are not. I wonder what y'all think.

https://github.com/MendyBerger/webidl-wit#conversions-from-webidl-to-wit-types

Contribute to MendyBerger/webidl-wit development by creating an account on GitHub.

view this post on Zulip Dan Gohman (Jan 03 2024 at 18:55):

This looks like a great start! I wouldn't be surprised if over time, Wit adds more types, like BigInt or finite-only floating-point types, and we can refine some of these, but what you have here looks good for now.

view this post on Zulip Mendy Berger (Jan 21 2024 at 01:02):

I'm thinking that it might make sense to make all function arguments borrow, since in JS everything is borrowed.

What do y'all think?


Last updated: Nov 22 2024 at 17:03 UTC