-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow fragments in a kebab name to start with a number #345
Comments
Some context here: Robin and I were chatting yesterday about some of the challenges of mechanically projecting various IDLs and programming languages to and from WIT. The |
There are lot's of such cases that I ran into while trying to convert WebIDL to wit, hope to write it down somewhere in the next few weeks. FWIW I'm skeptical that we can find solutions to all of these problems that would work nicely in all - or even most - languages. IIUC wit is (and should be) a subset of the capabilities of most languages. If we try to introduce behavior that languages don't naturally support, we might end up with API's that feel foreign and unintuitive. |
@MendyBerger Yes, that would be great - thank you!
@MendyBerger I mean; yes of course you're right. Creating great language-native bindings in the general case will always require additional work by library authors. Even simple abstractions like the WASI In my perspective, the goal of WIT, Wasm Components, and codegen tools is to automate as much of the process away as possible. So that even without manual projections the APIs are still usable. But with some additional work, they can be made to feel truly native. In the case of But while we may not be able to automatically generate perfect language-native bindings for each API every time; it's issues like these which enable us to improve on the status quo. So I'm happy you've been able to find some of those limitations already; and I look forward to you filing the issues so we can start thinking about how we can do better. |
Specifically about wrappers: I'm a bit concerned about requiring wrappers for components, I think we should aim to make them usable as is. Here are some reasons:
If we require wrappers for all components we'll lose all these advantages. I'd much rather spend the time now to build components that are usable as-is, than do it the quick way now and end up with components that feel weird to use without wrappers. Regardless, your and Robin's point still stands, if we can find solutions to specific problems that work well we should try to do it. (BTW I'll be mostly out until May 1st, so I might be slow to respond) |
I strongly agree with Mendy's take here: we've always tried to make bindings for components be "good enough" with a pretty high bar, to the point where an API should become usable in all languages without any extra work, and everything a wrapper would add is nice-to-have. There are certain APIs where that is probably never going to really work, but I don't think those are arguments for dropping the approach. As an example, Most APIs don't have that kind of constraint though, and I think we should optimize WIT as a language and wit-bindgen and other toolchains for those APIs, not the hard cases. |
Actually, let's back up here a little. I feel like we're about to get side tracked into a discussion about how good our bindings currently are, and whether we can hypothetically generate perfect bindings for all languages. I don't think this is the right venue for that. Instead, let me state what I believe we all agree on, in the hopes of moving this conversation forward:
Does anyone here disagree with this? |
I agree with all that, yes—including the venue thing. Thank you for that! ❤️ |
@yoshuawuyts I definitely agree with 1 and 3. |
FWIW, if we only allow the non-first- |
A kebab name in the current spec is made up of one or more "fragments" separated by a hyphen (
-
). These fragments can't begin with a number.However, there are examples in WebIDL that will need to be translated to WIT where either a name part or the whole name starts with a number.
GPUExtent3D
->gpu-extent-3d
GPUSize32
->gpu-size-32
GPUTextureDimension
cases "1d", "2d", and "3d" ->1d
,2d
,3d
The main concern to my knowledge with letting fragments/identifiers start with numbers is that these are translated into programming language identifiers which typically don't allow identifiers to start with numbers. However, many languages have techniques available in their grammar to handle these cases when translating names (e.g. mapping
1d
to_1d
in Rust).WIT authors on the other hand have relatively few options for handling these. They could either manually use domain/convention knowledge (e.g.
1d
asd1
), which isn't possible using automated tools like in-progress WebIDL -> WIT efforts, or add arbitrary prefixes to the front of their interface (e.g.c1d
for case1d
).I think that making bindings generators find language-specific ways to handle making identifiers valid will be better than forcing WIT authors to write names that don't begin with numbers, so we should consider letting all fragments in names start with numbers.
The text was updated successfully, but these errors were encountered: