Viewing old version a56146a9bd3863d4f0062ea5016063a82c0df65f; View Current
Scala Packages gives an overview of what packages in Scala are.
On the surface, they are a slightly more flexible version of Java’s imports:
You can also import packages anywhere you want, and those imports will be applied to the given scope. This lets you keep code a bit cleaner by reducing the scope of available symbols and classes to only the most minimal.
However, this doesn’t really touch on some of the subtleties of how Scala treats packages.
Read This for a detailed overview of some very subtle behavior.
My Thoughts on this Feature
I think it’s a shame that packages in Scala are essentially packages in Java. Importing always seems like a compiler hint, that, in this day and age, seems ridiculous. It’s another example of Java’s love of repeating information already given (I have to tell the JVM not just which jars I need on my classpath, but also which classes from those jars I need at compile time?!?!? Why!??!). It would be so great if Scala had integrated real high-level package importing and not just made Java’s version slightly better.
I think the ability to rename a class is nice, but I can’t say I’ve ever wanted this feature, and feel it could lead to some really hard to follow code.
Further, the behavior described in the linked article is INSANE. Why would anyone want that behavior?
Last Updated 07/31/2009 at 08:10:45 PM by davecblog comments powered by Disqus
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.