-
Notifications
You must be signed in to change notification settings - Fork 240
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
Default parameters in constructors #1840
Conversation
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. |
830570b
to
8d40d92
Compare
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me - I'll also flag @jeddai as the reviewer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, I'm excited to have this in!
1d2e20a
to
b9f16a3
Compare
BREAKING CHANGE: Named arguments to struct constructors are now required. Note that this now allows default values before non-default ones, which previously lead to a syntax error in generated Python.
…t values in struct constructors BREAKING CHANGE: Named arguments are now required.
b9f16a3
to
2e5bc9f
Compare
UniFFI added support for async traits in mozilla/uniffi-rs#1981, but this is not yet released. This commit temporarily introduces a Git dependency on UniFFI to let us test the async functionality which was removed in awslabs#86. An unrelated UniFFI change (mozilla/uniffi-rs#1840) made our existing test fail.
UniFFI added support for async traits in mozilla/uniffi-rs#1981, but this is not yet released. This commit temporarily introduces a Git dependency on UniFFI to let us test the async functionality which was removed in awslabs#86. An unrelated UniFFI change (mozilla/uniffi-rs#1840) made our existing test fail.
UniFFI added support for async traits in mozilla/uniffi-rs#1981, but this is not yet released. This commit temporarily introduces a Git dependency on UniFFI to let us test the async functionality which was removed in awslabs#86. An unrelated UniFFI change (mozilla/uniffi-rs#1840) made our existing test fail.
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.