What is the purpose of $ scope in scala.Predef?

scala.Predef contains the following code:

 // Apparently needed for the xml library val $scope = scala.xml.TopScope 

Has anyone found out why this is necessary, given that it creates dependencies on packages that could easily be separated from the standard library?

+6
source share
1 answer

Take a look at src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala and the result of parsing the XML literal.

 scala -Xprint:parser -e '<node/>' new _root_.scala.xml.Elem(null, "node", _root_.scala.xml.Null, $scope) 

Ideally, this moves somewhere under scala.xml ; try and see what happens.

+4
source

Source: https://habr.com/ru/post/896083/


All Articles