Stream: wit-bindgen

Topic: ✔ Recursive structures


view this post on Zulip Karel Hrkal (kajacx) (Mar 23 2024 at 19:40):

Hello, I am trying to create a "JSON-like" general value for settings, and I want to include a list of settings as an option, like this:

variant param-value {
    toggle(bool),
    integer(s64),
    float(float64),
    text(string),
    array(list<param-value>),
  }

This, however, throws an error: type param-value depends on itself. On one hand, it makes sense (can't have a recursive record), but on the other hand, the "recursion" is inside a list, and list will always use indirection, so this shouldn't be an issue.

I am using wit bindgen 0.15.0, so let me know if this is fixed in an updated version.

view this post on Zulip Lann Martin (Mar 23 2024 at 22:00):

The component model does not yet support recursive value types: https://github.com/WebAssembly/component-model/issues/56

There was some discussion on recursive types in WebAssembly/interface-types#137. My takeaway was that recursion would be hard to specify with adapter functions. With adapters punted to a post-MVP p...

view this post on Zulip Karel Hrkal (kajacx) (Mar 30 2024 at 12:49):

Thanks. I ended up JSON-encoding the settings and sending a string across the wit boundary.

view this post on Zulip Notification Bot (Mar 30 2024 at 12:49):

Karel Hrkal (kajacx) has marked this topic as resolved.


Last updated: Dec 23 2024 at 12:05 UTC