10000 Name boolean arguments by retronym · Pull Request #2164 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Name boolean arguments #2164

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

Closed
wants to merge 4 commits into from
Closed

Conversation

retronym
Copy link
Member

What would you prefer?

adaptToMemberWithArgs(tree, qual, name, mode, false, false)

Or:

adaptToMemberWithArgs(tree, qual, name, mode, reportAmbiguous = false, saveErrors = false)

compiler, reflect, and library have been swept.

A sanity check is included to show that using named args for clarity incurs no bytecode penalty.

Review by @paulp. Minor chuckles here: https://github.com/retronym/scala/pull/new/topic/bool-arg#L62L15

What would you prefer?

  adaptToMemberWithArgs(tree, qual, name, mode, false, false)

Or:

  adaptToMemberWithArgs(tree, qual, name, mode, reportAmbiguous = false, saveErrors = false)
@retronym
Copy link
Member Author

Hat tip to @Alefas for the recent improvements to the IntelliJ Scala plugin that means I can now run its inspections over our codebase.

@lrytz
Copy link
Member
lrytz commented Feb 24, 2013

would be nice to know that it doesn't add add any bytecode (i.e. that the names got eliminated at compile time) - did you check that maybe..?

@retronym
Copy link
Member Author

@lrytz No, i didn't check. Are you worried about the arguments being in a different order to the the parameters?

@lrytz
Copy link
Member
lrytz commented Feb 24, 2013

no, i was thinking of a sanity check for the named arguments implementation, that it doesn't generate any assignment blocks if things are in order. i should add some bytecode tests for that..

@retronym
Copy link
Member Author

@lrytz I've added a test for that.

When named arguments correspond the the parameter declaration
order, the compiler should not lift out assignments before
the method call, as it would have to do for out-of-order
arguments.

Confirm this with a bytecode comparison test.
@lrytz
Copy link
Member
lrytz commented Feb 24, 2013

nice thanks!

@ghost ghost assigned paulp Feb 24, 2013
@paulp
Copy link
Contributor
paulp commented Feb 25, 2013

I think we should work harder to eliminate boolean parameters before we serve as their enablers. This patch, while unarguably better considered in isolation at a frozen moment in time, also serves to:

  • entrench these parameters much more deeply
  • but since nothing makes future people use the names, we still require ongoing maintenance

I think quite a few of them can be eliminated with simply better thought out structure, and of whatever is left, we should be sure they carry an excellent name before we give every call site a dependency on it.

@paulp
Copy link
Contributor
paulp commented Feb 25, 2013

Also, I couldn't find the minor chuckles. I think that link is particular to you (for creating a pull request.)

@retronym
Copy link
Member Author

Here are the chuckles. https://github.com/scala/scala/pull/2164/files#L62L15

@paulp
Copy link
Contributor
paulp commented Feb 25, 2013

Ha! The only way the chuckles could have been less minor is if you had had to reorder the parameters (i.e. the comments had bitrotted.)

@retronym
Copy link
Member Author

So I don't buy the argument that we should avoid the merely good because we'll then be too lazy to go for the great. All too often, we're left with the bad.

It is still straightforward to improve the parameter names / eliminate boolean parameters after the fact using the same refactoring tools.

But let's be concrete and use this review to highlight sub-optimal names and a the most-wanted list for boolean parameters elimination.

@paulp
Copy link
Contributor
paulp commented Mar 5, 2013

Looking through the list of methods taking boolean arguments, I literally did not see a single one I did not want to put on the list for methods which should be written not to take boolean arguments. That said, I'll go along with the "merely good".

@paulp
Copy link
Contributor
paulp commented Mar 5, 2013

Superseded by #2203.

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.

3 participants
0