links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to reference names defined in other modules
Last updated at 5:16 am UTC on 11 March 2005
This page describes the rules for referring to names defined by modules that your module depends on. (See How to declare module dependencies.)

Full qualification currently doesn't work. However, it will not be needed until strong modularity is activated.

Imported names

Imported names from other modules can be referenced just like global variables in non-modular Smalltalk-80. I.e. these names do not have to be fully qualified.
A dependent module imports all the names of a module by specifying
     ...importNames: true
in the dependency declaration message.

Fully qualified name references

In a fully qualified reference you specify exactly which module a certain global name should be taken from, by preceding the actual name by the alias to the module it belongs to.
    morph _ Morphic Component
The alias is specified in the module dependency declaration.

Disambiguating imported names

Sometimes you need to full qualification to disambiguate imported names, because the name appears in more than one of the modules your module imports. For example, to distinguish between two classes with the same name but in different modules, in your code you would use
    morph _ Morphic Component
to distinguish a Morph class from a class in a super-meta-reflective programming system:
   ... externalModule: #(Project FancyMetaProgramming) alias: #MetaSystem ...
    model _ MetaSystem Component new

How full qualification works

    morph _ Morphic Component
"Morphic" is the alias to the module you declared. More precisely, Morphic is declared as a global variable in your module, and the value of this variable is the external module you specified.
So in "Morphic Component", what you really do is to send the message #Component to the variable Morphic. I.e. it is a message of the form
    theExternalModule messageToAccessExportedName
This is a mechanism for accessing the names exported by a module by sending a message to the module. The name of the message corresponds to the name you wish to access. This looks weird because Smalltalk messages usually begin with a lowercase letter. However, since modules are a new concept of the language there is a need for introducing a new convention for expressing it. Other approaches have been taken by other Smalltalks and I think they are much less appealing than this one.