uniffi-rs
uniffi-rs copied to clipboard
Default parameters in constructors
~~This PR is a two-parter:~~
The first 2 commits essentially implement what we discussed in #1658:
Struct constructors use named parameters in the foreign language.
This is enforced for Ruby and Python. Swift enforces it by default anyway, in Kotlin it's optional but usable (I don't think one can enforce the names)
That means default values at any position just work.
Note: default values for constructors aren't implemented for Ruby in main right now at all.
~~The last commit looks at default values in functions:~~ ~~Right now we happily accept default values for any of the arguments, which will break for Python and Ruby if any defaulted args come before non-defaulted ones.~~
~~I put this up as one PR for now, but that doesn't mean it's final.~~ ~~I'd be happy to split it up later.~~ ~~Personally I think for constructors it's not so controversial anymore (but awaiting final decision in #1658).~~ ~~For functions it's unclear right now.~~
In order to get something landed and to reduce the scope I'm splitting this in two: the record constructor and the normal function and its argument's order.
This PR is now purely for the constructor as that seems uncontroversial.
There's a bunch of tests that are affected by this change. So I'll wait for feedback if we go with this before spending the time on fixing them.