Scala Programming Language
  1. Scala Programming Language
  2. SI-5370

Function1/PartialFunction ScalaDocs violate LSP

    Details

      Description

      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.

        Activity

        Hide
        Daniel Sobral added a comment - - edited

        I opened pull request 100 to enhance the description.

        Show
        Daniel Sobral added a comment - - edited I opened pull request 100 to enhance the description.
        Hide
        Paolo G. Giarrusso added a comment -

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

        Show
        Paolo G. Giarrusso added a comment - Thanks for the prompt response! I added a comment about the wording on the pull request itself, since there I can specify it inline.
        Hide
        Paolo G. Giarrusso added a comment -

        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.

        Show
        Paolo G. Giarrusso added a comment - 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.
        Hide
        Grzegorz Kossakowski added a comment -

        Unassigning and rescheduling to M7 as previous deadline was missed.

        Show
        Grzegorz Kossakowski added a comment - Unassigning and rescheduling to M7 as previous deadline was missed.
        Hide
        Adriaan Moors added a comment -

        Clarified in the upcoming markdown spec.

        Show
        Adriaan Moors added a comment - Clarified in the upcoming markdown spec.

          People

          • Assignee:
            Adriaan Moors
            Reporter:
            Paolo G. Giarrusso
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development