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

Move *io* as first argument of method overloads #5925

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Apr 5, 2018

Fixes #5916

Copy link
Contributor

@ysbaddaden ysbaddaden left a comment

Choose a reason for hiding this comment

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

That's very very odd.

Optional parameters supposed to come after required arguments. I really don't like:

  • join(separator) —allright
  • join(io, separator) —what?!

@@ -2,11 +2,11 @@ require "spec"
require "big"

private def to_s_with_io(num)
String.build { |str| num.to_s(str) }
String.build { |io| num.to_s(io) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated change. I also prefer the str idiom for String.build. We're building a string, not whatever io.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can revert that.

But I always find this weird ("why is this passing a String?"): str is not a string but a string builder (so it would make sense to call it builder). Which is an IO and io is shorter but equally expressive. The argument in the method definition of to_s is also called io. So it makes very much sense to call this io.

@ysbaddaden
Copy link
Contributor

Maybe injecting the io in middle of arguments is a hint that some arguments should be named arguments (thus optional)?

@straight-shoota
Copy link
Member Author

straight-shoota commented Apr 5, 2018

@ysbaddaden Could we keep the general discussion about this in #5916, please?

@straight-shoota straight-shoota force-pushed the jm/fix/standardize-io-argument branch from 7ae22bc to ca3c657 Compare April 5, 2018 16:16
@straight-shoota straight-shoota force-pushed the jm/fix/standardize-io-argument branch from 216abdd to 5a1cde2 Compare April 5, 2018 16:39
@Sija
Copy link
Contributor

Sija commented Apr 5, 2018

@straight-shoota You meant #5916?

@straight-shoota
Copy link
Member Author

Closing. There has been no resolution on this and the PR would need a huge rebase, so it would be easier to start fresh.

@straight-shoota straight-shoota deleted the jm/fix/standardize-io-argument branch November 18, 2021 17:44
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.

Standardize overloads for methods with IO/returning String
3 participants