Skip to content
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

[std] improve haxe.Rest docs and mention ... syntax #10010

Merged
merged 2 commits into from
Dec 23, 2020

Conversation

Gama11
Copy link
Member

@Gama11 Gama11 commented Dec 19, 2020

No description provided.

Should be used as a type for the last argument of a method, representing that
arbitrary number of arguments of given type can be passed to that method.
```haxe
function f(...rest:Int) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it just me or using element type like :Int here feels weird?..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean, that's the whole point of the ... syntax?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, i think every language i saw so far use the array type for the actual rest arg local var. as i said, maybe it's just a habit, but to me this reads like rest is an Int, but it's actually not, I don't know...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, at least Java and Kotlin do it like this. I hadn't ever really noticed that TS and C# do it differently, probably because I use varargs so rarely...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh well ^^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't understand why we support ... in function definition, function f(...rest:Int) {} isn't clear at all imo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not too late to cut it out :)
To me it looks consistent with allowing call(...collection) at call site.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin seems even weirder in that regard (fun f(vararg rest:Int) and then f(*args)) :)

@RealyUniqueName RealyUniqueName merged commit 844cbe6 into development Dec 23, 2020
@Gama11 Gama11 deleted the Gama11-patch-1 branch December 23, 2020 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants