You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this is a perfectly valid use case for languages like JS and C++, as result<> return type are lowered into blob directly, using exceptions to propagate error-type values if they occur. This is what happens already with normal methods that return result<>.
Thoughts? I wonder if it is possible to enable this use case. Without it, APIs are forced to use alternative static methods like create: static func(), which is not standard, and hurts readability/discoverability.
Totally agreed; we should definitely do this. I believe #285 makes this same point, so perhaps we can dup this to that?
Spec-wise, the change is very simple; we just relax the validation rules for [constructor]...-named functions to also allow result. Most of the work would be in wit-bindgen and related tools. Let me know if anyone is keen to work on this!
Today, the following syntax is illegal, since constructors have no return types:
However, this is a perfectly valid use case for languages like JS and C++, as
result<>
return type are lowered intoblob
directly, using exceptions to propagateerror-type
values if they occur. This is what happens already with normal methods that returnresult<>
.Thoughts? I wonder if it is possible to enable this use case. Without it, APIs are forced to use alternative static methods like
create: static func()
, which is not standard, and hurts readability/discoverability.Moved from bytecodealliance/wit-bindgen#1114
The text was updated successfully, but these errors were encountered: