Uploaded image for project: 'Suggestions'
  1. Suggestions
  2. SUGGEST-23

Support for case classes should be part of a library and extensible, just like everything in Scala

    Details

      Description

      Abstract: Declaring a case class saves boilerplate, but is inflexible because support for case classes is built-in. Various use cases require small variations of case classes. I argue that one should support them through a separate compiler plugin, activated by a "@case" annotation. Existing bugs which could be addressed should be linked here.

      Programming in Scala (2nd edition, Sec. 1.1 page 51) states that "Instead of providing all constructs you might ever need in one "perfectly complete" language, Scala puts the tools for building such constructs into your hands".
      However, case classes are an exception, and one often needs to generate only part of what "case" generates.
      More in general, since Scala provides nothing resembling a macro language, neither syntactic nor lexical abstractions, Scala's syntax has quite a number of complex special cases - for instance case classes.
      Lacking macros, Scala supports compiler plugins and annotations; I propose that case classes are deprecated and replaced by a plugin desugaring appropriate annotations and easy to extend.
      An even better alternative would be to implement case classes through something like Template Haskell.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                pggiarrusso Paolo G. Giarrusso
              • Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: