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

2.9.0.RC5: Enumeration missing methods (comparing: 2.8.1.final) #4571

Closed
scabug opened this issue May 12, 2011 · 8 comments
Closed

2.9.0.RC5: Enumeration missing methods (comparing: 2.8.1.final) #4571

scabug opened this issue May 12, 2011 · 8 comments
Labels

Comments

@scabug
Copy link

scabug commented May 12, 2011

Comparing with version 2.8.1.final too many methods have been removed from Enumeration:
I can understand the removal of the concurrency methods( wait, notify etc) and the odd names with $$ and _ signs
which I don't know what they are for (they look like internal methods which shouldn't have been exposed).

But I don't understand the removal of the useful ones (mostly typical list methods) like:

value
valueOf
equals
exists
filter
flatmap
forAll
foreach
getClass
hashCode
iterator
map
name
nextId
nextName
readResolve
valueOf

Because of the missing of "valueOf" I found this difference.
Btw: I mentioned nextId, nextName and readResolve for completeness but I don't know what they are for.

C:\Users\Dave>c:\scala-2.8.1.final\bin\scala
Welcome to Scala version 2.8.1.final (Java HotSpot(TM) Client VM, Java 1.6.0_1
.
Type in expressions to have them evaluated.
Type :help for more information.

scala> object WeekDay extends Enumeration("Sun", "Mon", "Tue", "Wed", "Thu", "
i", "Sat") {
| type WeekDay = Value
| val Sun, Mon, Tue, Wed, Thu, Fri, Sat = Value
| }
defined module WeekDay

scala> WeekDay.

Fri Mon
Sat Sun
Thu Tue
Value ValueSet
ValueSet$$module Wed
apply asInstanceOf
equals exists
filter flatMap
forall foreach
getClass hashCode
isInstanceOf iterator
map maxId
name nextId
nextId_= nextName
nextName_= notify
notifyAll readResolve
scala$$Enumeration$$$$nameOf scala$$Enumeration$$$$nextNameOrElse
scala$$Enumeration$$$$nmap scala$$Enumeration$$$$populateNameMap
scala$$Enumeration$$$$topId scala$$Enumeration$$$$topId_=
scala$$Enumeration$$$$vmap scala$$Enumeration$$$$vsetDefined_=
toString valueOf
values wait
withName

C:\scala-2.9.0.RC5\examples>scala
Welcome to Scala version 2.9.0.RC5 (Java HotSpot(TM) Client VM, Java 1.6.0_18).
Type in expressions to have them evaluated.
Type :help for more information.

scala> object WeekDay extends Enumeration("Sun", "Mon", "Tue", "Wed", "Thu", "Fr
i", "Sat") {
| type WeekDay = Value
| val Sun, Mon, Tue, Wed, Thu, Fri, Sat = Value
| }
defined module WeekDay

scala> WeekDay.
Fri Mon Sat Sun Thu
Tue ValueSet Wed WeekDay apply
asInstanceOf isInstanceOf maxId toString values
withName

scala> WeekDay.

@scabug
Copy link
Author

scabug commented May 12, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4571?orig=1
Reporter: DaveScala (davescala)
See #5211

@scabug
Copy link
Author

scabug commented May 12, 2011

DaveScala (davescala) said:
Better formatting:
Comparing with 2.8.1.final too many methods have been removed from Enumeration:
I can understand the removal of the concurrencymethods( wait, notify etc) and the odd names with $$ and _ signs which I don't know what they are for (they look like internal methods which shouldn't be exposed).

But I don't understand the removal of the useful ones (mostly typical list methods) like:

value
valueOf
equals
exists
filter
flatmap
forAll
foreach
getClass
hashCode
iterator
map
name
nextId
nextName
readResolve
valueOf

Because of the missing of "valueOf" I found this difference.
Btw: I mentioned nextId, nextName and readResolve for completeness but I don't know what they are for.

C:\Users\Dave>c:\scala-2.8.1.final\bin\scala
Welcome to Scala version 2.8.1.final (Java HotSpot(TM) Client VM, Java 1.6.0_1
.
Type in expressions to have them evaluated.
Type :help for more information.

scala> object WeekDay extends Enumeration("Sun", "Mon", "Tue", "Wed", "Thu", "
i", "Sat") {
     |    type WeekDay = Value
     |    val Sun, Mon, Tue, Wed, Thu, Fri, Sat = Value
     | }
defined module WeekDay

scala> WeekDay.

Fri                                  Mon
Sat                                  Sun
Thu                                  Tue
Value                                ValueSet
ValueSet$$module                      Wed
apply                                asInstanceOf
equals                               exists
filter                               flatMap
forall                               foreach
getClass                             hashCode
isInstanceOf                         iterator
map                                  maxId
name                                 nextId
nextId_=                             nextName
nextName_=                           notify
notifyAll                            readResolve
scala$$Enumeration$$$$nameOf            scala$$Enumeration$$$$nextNameOrElse
scala$$Enumeration$$$$nmap              scala$$Enumeration$$$$populateNameMap
scala$$Enumeration$$$$topId             scala$$Enumeration$$$$topId_=
scala$$Enumeration$$$$vmap              scala$$Enumeration$$$$vsetDefined_=
toString                             valueOf
values                               wait
withName



C:\scala-2.9.0.RC5\examples>scala
Welcome to Scala version 2.9.0.RC5 (Java HotSpot(TM) Client VM, Java 1.6.0_18).
Type in expressions to have them evaluated.
Type :help for more information.

scala> object WeekDay extends Enumeration("Sun", "Mon", "Tue", "Wed", "Thu", "Fr
i", "Sat") {
     |    type WeekDay = Value
     |    val Sun, Mon, Tue, Wed, Thu, Fri, Sat = Value
     | }
defined module WeekDay

scala> WeekDay.
Fri            Mon            Sat            Sun            Thu
Tue            ValueSet       Wed            WeekDay        apply
asInstanceOf   isInstanceOf   maxId          toString       values
withName

scala> WeekDay.

@scabug
Copy link
Author

scabug commented May 12, 2011

@hubertp said:
These have been deprecated in 2.8 and you can still get the same functionality using other methods.
For example foreach => values.foreach, map => values.map, valueOf => withName etc.

@scabug
Copy link
Author

scabug commented May 12, 2011

DaveScala (davescala) said:
Thanks for your anwer. Refactoring is a good thing. But sometimes not very obvious to find the same functionality back.

Hopefully this will be well documented in a sort of "Quick 2.8.1 -> 2.9.0 migration" document or else in the api documentation.

I close this ticket then.

@scabug
Copy link
Author

scabug commented May 12, 2011

DaveScala (davescala) said:
I have one more question though, because I don't know what the "rule" is in scalac concerning deprecated apis.

When I compile this file which uses a deprecated valueOf method I get an error but some other deprecated apis get a message with "run scalac with -deprecation" or alike

C:\scala-2.9.0.RC5\examples>scalac scalaenums.scala
scalaenums.scala:8: error: value valueOf is not a member of object scalaenums.We
ekDay
   println(WeekDay.valueOf("Wed")) // returns Some(Wed)
                   ^
one error found

I reopen this ticket because I am not sure if the ticket can be seen by you if I post on a closed ticket.

@scabug
Copy link
Author

scabug commented May 12, 2011

@paulp said:
You get an error because you're not compiling against a deprecated method, you're compiling against a method which isn't there. It was deprecated a long time ago. First it is deprecated, then it is removed.

@scabug
Copy link
Author

scabug commented May 12, 2011

DaveScala (davescala) said:
Okay thanks, deprecated in 2.8.1.final
Probably people who skip some versions of Scala will miss the deprecation warning, though.

C:\scala-2.8.1.final\examples>C:\scala-2.8.1.final\bin\scalac.bat scalaenums.sca
la
warning: there were deprecation warnings; re-run with -deprecation for details
one warning found

C:\scala-2.8.1.final\examples>C:\scala-2.8.1.final\bin\scalac.bat -deprecation s
calaenums.scala
scalaenums.scala:8: warning: method valueOf in class Enumeration is deprecated:
use withName instead
   println(WeekDay.valueOf("Wed")) // returns Some(Wed)
                   ^
one warning found

@scabug
Copy link
Author

scabug commented May 12, 2011

@paulp said:
Replying to [comment:6 DaveScala]:

Okay thanks, deprecated in 2.8.1.final
Probably people who skip some versions of Scala will miss the deprecation warning, though.

Also deprecated in 2.8.0. The last version it appeared undeprecated was 2.7.7. If the people missing those warnings thought they could jump from 2.7.7 to 2.9.0 and recompile, they were going to have to find out otherwise anyway.

@scabug scabug closed this as completed May 18, 2011
@scabug scabug added the enum label Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant