-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add sym shorthand for Symbol #7495
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
Conversation
4a49645 to
a3dca0b
Compare
|
Symbol literals supported pattern matching: 'foo match {
case 'bar => ...
}This shorthand syntax, using sym"foo" match {
case sym"bar" => ...
}It is possible to match using the sym"foo" match {
case Symbol("bar") => ...
}Is it possible to make |
|
You can have an unapply on a string interpolator, see for example #7387 |
a3dca0b to
418ea3e
Compare
|
@smarter Exciting! Thanks for pointing that out. |
4d219a9 to
f5f2e5c
Compare
8d947fe to
dbcc44b
Compare
|
Using this syntax throughout the compiler was successfully experimented with in #7499. |
dbcc44b to
e217f76
Compare
|
I tried using this syntax in the 2.12 version of the community build, see scala/community-build#827 I forked 24 community projects that had literal symbols in their build. I added the new symbol syntax to these builds, and this resulted in 92 projects being built successfully.
There was one project of the 24 that the new symbol syntax could not be made to work:
Shapeless will either require some significant re-architecting to support symbols or dropping symbol literals entirely. I am not an expert, but I presume it is because Shapeless expects symbol literals to be available at the compiler/reflect level and not at runtime. There were 85 builds that didn't run in the community build because a dependency failed to build or because shapeless can't build. |
/cc @milessabin |
|
I may have overstated the situation in my last comment. There's evidence that |
SethTisue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for merge after squash
abcc432 to
1816c84
Compare
This comment has been minimized.
This comment has been minimized.
|
thanks Aaron for your diligence on this. I think #7395 will be merged soon as well |
|
I am saddened that this feature of Lisp heritage will likely go away, but despite my best efforts I couldn't find a compelling reason to keep it. There's a chance something could still come up that would preclude it. I'm not an expert, but I would bet against such a possibility. |
|
it's a bit sad we can't backport the new interpolator to 2.12.x, because bincompat. I guess cross-builders can use the |
|
It could also be implemented in a compat library. |
|
I find https://contributors.scala-lang.org/t/proposal-to-deprecate-and-remove-symbol-literals/2953/22 a pretty compelling argument against this PR (note the author on both ;-)). Should we revert this PR to avoid introducing too many ways of doing the same thing, especially since it likely won't help cross-building? |
|
reverted by #7917 |
UPDATE: this was reverted by #7917
In scala/scala-dev#459, there was a suggestion to provide a string variant to replace the symbol quote syntax:
This is a work-in-progress for discussion on providing an alternative so quote syntax can be deprecated. As implemented with
StringContext, it supports interpolation as well.I've disabled the test suite so that only the new test runs.