Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple packages definition

Tags:

package

scala

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?

like image 894
Mr_Qqn Avatar asked Aug 22 '10 10:08

Mr_Qqn


People also ask

What is a package marketing?

Packaging is a subset of marketing where a brand designs and develops the wrapper or container to aid its transport, handling, delivery, and communicate the brand and product information by making it look attractive.

What is family packaging?

Definition. Family packaging refers to the use of one design or other key packaging element to integrate the packaging of two or more individual items (for example, a personal care line that includes shaving cream, after-shave and antiperspirant).

What is kaleidoscopic packaging?

Kaleidoscopic packaging is concerned with printing suitable and attractive cut-out figures, toy and cartoons on the package in order to attract the consumer and stimulate the demand. Pictures of fresh and juicy vegetables, fruits on ready to eat items give an impression of a healthy product.


2 Answers

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

like image 160
Landei Avatar answered Sep 21 '22 13:09

Landei


The Scala reference mentions (chapter 9, section 9.1):

A compilation unit consists of a sequence of packagings, import clauses, and class and object definitions, which may be preceded by a package clause.

A compilation unit

package p1; ... package pn; stats 

starting with one or more package clauses is equivalent to a compilation unit consisting of the packaging

package p1 { ...   package pn {    stats   } ... } 

See also Organizing Code in Files and Namespaces on nested packages.
(From Programming Scala: Scalability = Functional Programming + Objects By Dean Wampler, Alex Payne, page 44, Chapter 2)

like image 29
VonC Avatar answered Sep 20 '22 13:09

VonC