-
Notifications
You must be signed in to change notification settings - Fork 8
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
Multiple library products and union types #14
Comments
WebIDL doesn't really specify dependencies as far as I can tell, and any spec can define additional properties/methods on a type from any other spec. |
Ultimately I think we need an overlay with some manual citation of the generated code. For example, |
I agree. Not necessarily related to the issue of splitting into separate products, but we also need to do something about ugly |
I think for parameter types we should be able to make those union types into protocols, so that you can pass any value. That does mean the The ugly names are unfortunate, though. I have some code already that renames them to a human-readable name if they’re used inside a typedefs (i.e. a hypothetical |
Is there a downside to my proposed overloads solution that makes you prefer union types as protocols over overloads? |
It would make the code generator more complicated (although that’s no justification, I simply means I’m lazy haha). But also due to the way Cartesian products work, we would end up with many same-named overloads if there were methods with multiple union-typed parameters. Finally, is it even possible to overload properties? They can have a union type too. |
This makes sense. BTW, protocols have a runtime performance overhead over enums, but I agree they may be more suitable as they are more flexible in terms of future additions. Enums are quite rigid, as we've already witnessed with CC @kateinoigakukun. |
Mmm, good point about the enums. Maybe we should make our union type’s concrete implementations be structs, then. Or maybe we don’t need a concrete type at all, just a function that can decode a // maybe an extension on JSValue? Maybe public or maybe internal?
func foo(_ value: JSValue) -> ObjectKey {
String.construct(from: value) ?? Double.construct(from: value)
} I wish there were a way to define methods directly on protocol existentials… |
For the performance overheads, if user passes a concrete type to a function that takes an existential abstracted type and the callee is inlinable, the boxing overheads can be omitted. Unlike |
This feature is very important in the aspect of build artifact size. Ideally, the size issue should be resolved by cross module DCE, but the latest compiler doesn't do it now, so we need to split modules carefully. |
I'm closing this as multiple library products are now available in |
Playing with the library a bit more, I think it would be great to split it into separate targets and products, if possible. As an example, people who don't need WebGL don't need to build WebGL wrappers, but I think it still makes sense to provide them.
IDK if WebIDL specifies dependencies between their "modules", so maybe we'd need to hardcode those on our side for things to work?
The text was updated successfully, but these errors were encountered: