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

Document that AnyVal "box" and "unbox" are implemented by BoxesRunTime #6898

Closed
scabug opened this issue Dec 31, 2012 · 4 comments
Closed

Document that AnyVal "box" and "unbox" are implemented by BoxesRunTime #6898

scabug opened this issue Dec 31, 2012 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Dec 31, 2012

As discussed in #6710 and on scala-lang [1], the "box" and "unbox" methods of AnyVal classes (except Unit) are not actually implemented by the code in AnyVal [2].

Instead, the real implementation comes from BoxesRunTime (e.g. [3]). This is functionally different, creating potential for confusion.

As per the scala-lang discussion and #6710, changing the AnyVal code itself would have too much potential impact and thus be too risky. Documenting the behaviour would be a safer option.

From Paul Phillips' comment:

"If we're not using it in generated code and don't intend to, the ideal change is probably to deprecate it and then remove it. Next best (and to do regardless) is to document the behavior and the fact that it isn't actually used by the compiler." [4]

Source code of AnyVal classes and screenshots of documentation after

ant all.clean
ant build
./tools/codegen-anyvals
ANT_OPTS="-Xms512M -Xmx1024M -Xss1M -XX:MaxPermSize=128M" ant docs

attached.

[1] https://groups.google.com/d/topic/scala-language/kBQnJ3XuKeM/discussion
[2] https://github.com/scala/scala/blob/master/src/compiler/scala/tools/cmd/gen/AnyVals.scala#L2321
[3] https://github.com/scala/scala/blob/master/src/library/scala/runtime/BoxesRunTime.java#L87
[4] https://groups.google.com/d/msg/scala-language/kBQnJ3XuKeM/qvLnORIiXqAJ

@scabug
Copy link
Author

scabug commented Dec 31, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6898?orig=1
Reporter: @demobox
Affected Versions: 2.10.0-RC5
Attachments:

  • anyvals-src.zip (created on Dec 31, 2012 1:08:27 PM UTC, 18533 bytes)
  • Boolean-doc.png (created on Dec 31, 2012 1:08:27 PM UTC, 38194 bytes)
  • Byte-doc.png (created on Dec 31, 2012 1:08:27 PM UTC, 34195 bytes)
  • Char-doc.png (created on Dec 31, 2012 1:08:27 PM UTC, 32471 bytes)
  • Double.png (created on Dec 31, 2012 1:08:27 PM UTC, 24307 bytes)
  • Float-doc.png (created on Dec 31, 2012 1:08:27 PM UTC, 26796 bytes)
  • Int-doc.png (created on Dec 31, 2012 1:08:27 PM UTC, 29609 bytes)
  • Long-doc.png (created on Dec 31, 2012 1:08:27 PM UTC, 28584 bytes)
  • Short-doc.png (created on Dec 31, 2012 1:08:27 PM UTC, 32382 bytes)
  • Unit-doc.png (created on Dec 31, 2012 1:08:27 PM UTC, 19152 bytes)

@scabug
Copy link
Author

scabug commented Dec 31, 2012

@scabug
Copy link
Author

scabug commented Feb 12, 2013

Lars Hupel (larsrh) said:
Is there any reason why the unbox methods shouldn't be deprecated for 2.11?

@scabug
Copy link
Author

scabug commented Mar 21, 2013

@demobox said:
Submitted pull request based on suggestion by @jsuereth:

scala/scala#2284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants