- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
package-level type alias
Mon, 2010-03-01, 20:20
Hello,
Using the scala 2.8 repl, the definition
type ObjTreeList = ListBuffer[Tuple2[EObject, String]]
works and can be used later in classes etc.
For the whole file, with structure
package foo
...
type ObjTreeList = ListBuffer[Tuple2[EObject, String]]
...
the eclipse plugin gives the error message
expecting class or object
and as result the file won't compile.
Are package-level type aliases not allowed, or is this a plugin issue?
If package-level aliases are not allowed, how can I get a meaningful
name for a final class like ListBuffer, short of introducing a whole
new class just to wrap a ListBuffer special case?
Thank you,
Mike
Mon, 2010-03-01, 20:57
#2
Re: package-level type alias
On Mon, Mar 01, 2010 at 11:44:57AM -0800, Paul Phillips wrote:
> package foo {
> type LB[T] = scala.collection.mutable.ListBuffer[T]
> }
Oops, of course I mean
package object foo { ... }
On Mon, Mar 01, 2010 at 11:20:10AM -0800, michael hohn wrote:
> Are package-level type aliases not allowed, or is this a plugin issue?
This is a large chunk of why package objects were created.
> If package-level aliases are not allowed, how can I get a meaningful
> name for a final class like ListBuffer, short of introducing a whole
> new class just to wrap a ListBuffer special case?
package foo {
type LB[T] = scala.collection.mutable.ListBuffer[T]
}
See the many files called package.scala in trunk for endless examples.