- About Scala
- In the Enterprise
- Scala Community
- Language Research
- In the Press
- The Scala Team
- Scala's Prehistory
- Contact Us
- Learning Scala
- Tour of Scala
- Scala API
- Setup & Getting Started
- Programming Guides
- Other Guides
- Code Examples
- Scala Developers
Random thoughts about class signatures in ScalaDoc.regarding Any/AnyRef/AnyVal/Nothing
I was just reading in ScalaDoc a bit and got annoyed of the "extends
in many class signatures.
It's not that classes wouldn't have enough things to inherit from
classes are a good example) :-), but maybe it is possible to decrease the
amount of clutter in the class signatures?
I'll try to sketch the way my thoughts went, eventually leading to the
decision to write this mail:
[It would be nice to not show Any and AnyRef in ScalaDoc since
every reference type inherits from them anyway...]
[But what about value types?]
[Maybe it would work using a different kind name for them?]
[Could it work to keep using class/trait/object for reference types
and replacing "final class Boolean/Int/... extends Any with AnyVal"
with something like "value Boolean/Int..."?]
[But what about Nothing? It is supposed to be a subtype
of everything... and the code says "final trait Nothing"]
[Better to use "type Nothing" maybe? The ScalaDoc also only
talks about "type/subtype" and not about "class/subclass" anyway.]
In the end, would it make sense to show a slightly more high-level view
of Scala's type hierarchy to the user, where Any/AnyRef/AnyVal isn't
shown explicitly in the type signature in favor of a more implicit
"class/trait/object Foo" => Foo must be subtype of AnyRef
"value Bar" => Bar must be subtype of AnyVal
"class/trait/object Foo extends AnyRef"
"final class Bar extends Any with AnyVal"
What about "final trait Nothing"?
While I like how that "impossible" modifier combination conveys
the idea of an "uninhabited" type, wouldn't it be nicer to
just use "type" instead?
(Considering the fact that the compiler displays a not very helpful
error message when trying to compile "final trait Baz" about
"illegal combination of modifiers: abstract and final"...)
Just some random thoughts I was thinking about ... I did no deep
type system theory, the ideas are just based on my personal taste.
What do you think?
Thanks and bye,