-
Notifications
You must be signed in to change notification settings - Fork 717
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
Emulate variadic methods using tuples #2276
Conversation
☔ The latest upstream changes (presumably 4b006da) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
I'm not sure how I feel about this, do you really think that this is worth it? As in, do you think that doing:
foo.printf(b"%d\0".as_ptr(), (a, b, c))
Is realistically much better than:
Foo_printf(foo, b"%s\0".as_ptr(), a, b, c)
?
The pros I see with approach are:
|
Oh this is great! As a user this would help in that rust analyzer (or any lsp) will finally suggest these methods |
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.
I approve, but will defer to @emilio.
35e24a6
to
e4f1143
Compare
☔ The latest upstream changes (presumably #2282) made this pull request unmergeable. Please resolve the merge conflicts. |
e4f1143
to
d1d7d70
Compare
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.
I still tend to think that this is very complex for the value it provides, but at the very least some things need to be fixed.
☔ The latest upstream changes (presumably #2284) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably 9c32b46) made this pull request unmergeable. Please resolve the merge conflicts. |
This PR introduces a new flag
--tuple-varargs-len=<LEN>
which can be used to emulate variadic methods using tuples of length up to<LEN>
.Example
If the generated function signature for a variadic method is:
and the
--tuple-varargs-len
flag is set. A new method for the typeFoo
is introduced:The user would use such method like this:
To do this, the
VarArgs
trait is declared and implemented automatically up to the value of--tuple-varargs-len
:This has some disadvantages, such as the user not being able to just do
foo.bar(a)
orfoo,bar(a, v)
without getting somewhat confusing errors but this could be mitigated by properly documenting theVarArgs
trait.Fixes #407