Magik Packages

Note Smallworld 5 doesn't support package inheritance of exemplars. Example, you cannot have user:version_management_plugin inherit from sw:version_management_plugin in smallworld 5.

Packages allow you to "bin" globals and exemplars together. "Most" programmers just program under the "user" package. Smallworld code is typically under the "sw" package.

Look at Main Help->Application Development Techniques->Using software modules and products->13 Use of packages in Smallworld products for details.

Definition

Use def_package() to define a new package to be used by the system. Note that this needs to be run before using the _package statement.

def_package( :auth_stuff, :uses, {:user} )

Adding Code to Packages

Use "_package" to identify what package the code is used. You can have several in a MAGIK file if you want to swap between packages (but why make life complicated?).

_package user
<OR>
_package my_code

Using Package

To get a global defined in a different package not within the "uses" list, use:

sw:!current_world!

Reporting

The package is a keyed set, so you can report the keys (globals or exemplar) and its value using hash methods like keys and fast-keys_and_elements(). Examples:

package(:sw).keys
<OR>
_for g,el _over package(:sw).fast_keys_and_elements()
_loop
   show(g,el)
_endloop
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License