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

Add Order instance for scala.Symbol #1395

Merged
merged 2 commits into from
Sep 28, 2016
Merged

Add Order instance for scala.Symbol #1395

merged 2 commits into from
Sep 28, 2016

Conversation

durban
Copy link
Contributor

@durban durban commented Sep 24, 2016

No description provided.

@codecov-io
Copy link

codecov-io commented Sep 24, 2016

Current coverage is 91.68% (diff: 100%)

Merging #1395 into master will increase coverage by <.01%

@@             master      #1395   diff @@
==========================================
  Files           239        240     +1   
  Lines          3607       3610     +3   
  Methods        3544       3546     +2   
  Messages          0          0          
  Branches         62         63     +1   
==========================================
+ Hits           3307       3310     +3   
  Misses          300        300          
  Partials          0          0          

Powered by Codecov. Last update b8603ec...318e456


class SymbolOrder extends Order[Symbol] {
override def eqv(x: Symbol, y: Symbol): Boolean =
x eq y
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to use == here? I assume Symbol's equal method is correct and we don't need to worry here that eq is correct.

Copy link
Member

Choose a reason for hiding this comment

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

Symbols are interned ... might as well take advantage of that fact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was my intention.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, I know that eq is how it is implemented due to the interning, but equals already does this:
https://github.com/scala/scala/blob/2.12.x/src/library/scala/Symbol.scala#L31

so, this, to me, assumes the jit may not do the job, yet each reviewer of the code has to recall this fact about how Symbol instances are created.

That said, I'm happy to simply add a comment here to explain this so that the code is clearer to someone unfamiliar (I think Symbol is actually rather unused as a scala feature these days).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, comment added in 318e456.

@johnynek
Copy link
Contributor

👍

1 similar comment
@kailuowang
Copy link
Contributor

👍

@kailuowang kailuowang merged commit a392654 into typelevel:master Sep 28, 2016
@durban durban deleted the topic/symbolOrd branch October 1, 2016 09:57
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.

5 participants