uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

Default parameters in constructors

Open badboy opened this issue 8 months ago • 2 comments

~~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.~~

badboy avatar Nov 10 '23 15:11 badboy