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

Change infix method calls o m a to o.m(a). #672

Merged
merged 1 commit into from
Jun 15, 2023
Merged

Change infix method calls o m a to o.m(a). #672

merged 1 commit into from
Jun 15, 2023

Conversation

dubinsky
Copy link
Contributor

@dubinsky dubinsky commented Jun 15, 2023

With infix method invocations falling out of fashion - and eventually, out of validity - maybe it is time to move away from them?

@dubinsky dubinsky changed the title Change infix method calls o m a to 0.m(a). Change infix method calls o m a to o.m(a). Jun 15, 2023
Copy link
Member

@SethTisue SethTisue left a comment

Choose a reason for hiding this comment

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

👏

@dubinsky dubinsky merged commit 26af21d into scala:main Jun 15, 2023
@Ichoran
Copy link

Ichoran commented Jun 16, 2023

Even eq? foo.eq(null) flows a lot less well than foo eq null to my eye. (Personally, I find the StringBuilder append a lot clearer infix too, but maybe I'm weird that way.)

@dubinsky
Copy link
Contributor Author

@Ichoran

Sorry, merged to eagerly :)

(Personally, I find the StringBuilder append a lot clearer infix too, but maybe I'm weird that way.)

You are not weird, I agree that sb append("<!ELEMENT ") append(name) append(' ') looks cleaner than sb.append("<!ELEMENT ").append(name).append(' '); but to me s"<!ELEMENT $name " looks cleaner still. Maybe #673 alleviates some of the damage to readability...

Even eq? foo.eq(null) flows a lot less well than foo eq null to my eye.

While I prefer a.equals(b) to a equals b, I agree that a eq b looks better than a.eq(b)... The goal of this pull request was not to codify my aesthetics though - it was to eliminate any and all infix method invocations, since they are no longer recommended and will eventually become illegal (although it'll be years before that affects us here).

I did not look into changing the code to use different methods on case-by-case basis as part of this pull request, but doing this should alleviate some of the readability issues; for instance, 9 out of 10 occurrences of a.ne(b) in the code are actually of the form a.ne(null) and could be replaced with the very readable a != null, couldn't they? Needless to say, your contributions in this or any other area are more than welcome :)

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