Skip to content

Plans for after Scala 3.0 #248

Open
Open
@ashawley

Description

@ashawley

There's a proposal to remove XML literals in Scala 3 ("dotty") and replace them with an alternative interpolated string library. The library has macro code that makes sure the XML in the string is well-formed at compile time.

This proposal is a long time coming and is not a big surprise, but how will this affect the development of scala-xml library?

Here are a few considerations:

  1. When the hooks for providing XML literals are removed in Scala 3 ("dotty"), it should be no problem for scala-xml. The scala-xml code doesn't know anything about the compiler hooks. Further, there aren't any significant bits in scala-xml for providing XML literals that is worth removing. The only things is the scala.xml.Properties singleton, which is four lines of code. The code for XML literals is entirely in the compiler. That code is actually an optional dependency on scala-xml starting with the 2.13 compiler.
  2. For that reason, the implementation of XML literals doesn't immediately require a separate version of scala-xml for Scala 3 with the XML literal support removed. Theoretically, the library could be cross-compiled to work with Scala 2 and Scala 3.
  3. The proposed XML interpolation library is planning to support XML literals with strings and the macro support in the compiler.
  4. The proposed XML interpolation library is planning to provide XML values as scala-xml data model (scala.xml.Node and friends).
  5. To compile in Scala 3, the scala-xml test suite will need to switch to either constructor based XML values or the new XML interpolation.
  6. To avoid a circular dependency between the test suite and the XML interpolation library, it would probably be better to just include interpolation in this project as was proposed in Xml Interpolation #151 as scala-xml-quote and publish it as a separate jar.
  7. Right now the sbt build defines a JVM and ScalaJS projects. We'll need to add a project for scala-xml-quote (call itquote?).
  8. The new scala-xml-quote does have new dependencies (scala-xml and fastparse) that are fine since it's a new and separate library
  9. However, publishing milestone builds for the Scala compiler team will become more difficult with these new dependencies in the scala-xml build.
  10. The Scala compiler no longer depends directly on scala-xml in 2.13, and there shouldn't be any important parts of the toolchain that require scala-xml to bootstrap the compiler.

We should probably take the opportunity to make a major release (scala-xml 2.0) with some of the following changes:

  1. Add scala-xml-quote to the repo as proposed in Xml Interpolation #151
  2. Migrate test suite from XML literals to XML interpolation
  3. Deprecate code marked deprecated
  4. Drop build support for Scala 2.12
  5. Switch to actually using the new Scala 2.13 collections
  6. Fix deprecation warnings, e.g. "X in package scala is deprecated (since 2.13.0)"

We can probably expect breaking changes for Scala 3 ("dotty") that might require breaking changes to scala-xml. That could require a new major version of scala-xml, which would be 3.0 and make a nice correspondence with Scala 3's version number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions