Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
868 views
in Technique[技术] by (71.8m points)

scala - Multiple packages definition

While browsing the source code of the Scala API, I met this package definition in scala/tags/R_2_8_0_final/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala:

package scala.util.parsing
package combinator
package syntactical

What does that mean? That the class will be available in more than one package?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is basically the same as

package scala.util.parsing.combinator.syntactical

import scala.util.parsing._
import scala.util.parsing.combinator._

...

So by "stacking" the packages the way you wrote you can get super-packages in scope. See also these answers.

[Update] Here is a new article written by Martin Odersky about this topic: http://www.artima.com/scalazine/articles/chained_package_clauses_in_scala.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...