PackageDescription: DefaultPackageNamespaces


Default Package Namespaces

Last published: November 21, 2004 by 'aknight'

Defines 1 Classes
Extends 34 Classes

This allows a package to specify a default namespace, using the #namespace property. Note that this is preliminary code, and may still have issues in unusual situations.

If a package specifies a default namespace, then
- class/namespace definitions automatically default to that namespace
- class extensions defined in the package are compiled in the scope of that namespace, rather than the namespace of the class. This can greatly reduce the need for qualified names in class extension methods.

Note that only packages (not bundles) can currently specify namespaces, because of the ambiguity of specifying a namespace at both bundle and package level.

Also note that this relies on the presence of packages. If you save packages which use this mechanism as a parcel, then load into an image without packages (i.e. a non-Store image) then the namespaces will be preserved, and the code will run, but when you recompile any of the extension methods, they will revert to being compiled in the containing class's namespace. This should not be a problem for deploying a normal runtime, but could be a problem if deploying in a development image or in a runtime that expects to recompile its own code.

This currently has extremely minimal tool support, which we hope to improve in future versions. The property can be specified either in the "other" properties of the package, by doing (1) add field #namespace from the left-hand pop-up (2) select #namespace in that list (3) replace nil with the *string* representing the name of the namespace (4) pop up the menu and "accept" that change (5) click on "Apply". Alternatively you can use the Associate w/ namespace menu item from the package list in the browser. To tell if a package is associated with a namespace, select the package, or a class within the package and look at the title bar of the browser. The associated namespace will be listed inside curly braces.