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

Function1/PartialFunction ScalaDocs violate LSP #5370

Closed
scabug opened this issue Jan 13, 2012 · 5 comments
Closed

Function1/PartialFunction ScalaDocs violate LSP #5370

scabug opened this issue Jan 13, 2012 · 5 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Jan 13, 2012

There is much confusion about PartialFunction vs Function1, and I believe this is caused by lack of documentation. Specifically, the following mail from Martin Odersky is not reflected in Function1/PartialFunction ScalaDocs, as of 2.9.1:
http://article.gmane.org/gmane.comp.lang.scala.internals/2057

Specifically, Function1 ScalaDocs should explain that the domain is not specified, while PartialFunction ScalaDocs should explain that the domain is now specified, and should clarify (once and for all) whether PartialFunction.apply is allowed to throw exceptions on the domain. In particular, I believe that it should be allowed, otherwise the following code should become illegal:
val f: PartialFunction[Int, Any] = { case _ => 1/0 }
(it compiles on Scala 2.9.1 REPL).
Aaron Novstrup* suggested that whenever PartialFunction.apply throws an exception, that exception must be "part of the design of the function (and should be documented)", which makes sense.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jan 13, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5370?orig=1
Reporter: @Blaisorblade
Affected Versions: 2.9.1

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jan 13, 2012

@dcsobral said (edited on Jan 13, 2012 5:12:17 PM UTC):
I opened pull request 100 to enhance the description.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jan 13, 2012

@Blaisorblade said:
Thanks for the prompt response! I added a comment about the wording on the pull request itself, since there I can specify it inline.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Feb 10, 2012

@Blaisorblade said:
I noticed that the wording problem also affects the Scala Language Reference (as in release 2.9.1), which in Sec 12.3.3 "The Function Classes" says that "A subclass of Function1 represents partial functions, which are undefined on some points in their domain."
The pull request was merged; after also fixing the language reference (if it is still a problem), this bug could be closed.

@scabug scabug closed this Mar 12, 2014
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Mar 12, 2014

@adriaanm said:
Clarified in the upcoming markdown spec.

@scabug scabug added this to the 2.11.0-RC3 milestone Apr 7, 2017
@scala scala deleted a comment from scabug Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.