Modules provide a mechanism so that ScriptX programs can be
packaged into components-components that can be compiled,
managed, and integrated into other ScriptX programs without
naming conflicts.
ModuleClass
does not inherit
from Collection
, a module is best understood as a
collection of name bindings. When a module is added to a title
container, it stores its name bindings for classes, objects,
functions, and variables to disk. This feature is useful as a
mechanism for storing and retrieving compiled classes,
functions, variables and objects.in module
expression, all objects defined while
executing in former module remain in memory. Any bindings that
exist in the former module still exist, and can be used when
that module becomes the current module again. Nor does loading
a new module load any objects that the new module defines. A
program must explicitly create or load any objects it
defines. Chapter Summary and Organization
"Module Concepts" on page 188 continues the discussion in the previous section, exploring underlying ideas that are necessary for defining your own ScriptX modules.
"Defining and Using Modules" on page 196 presents the syntax for creating a module in ScriptX, and for switching the compiler environment between modules. This section defines all the syntax for importing and exporting names and variables between modules.
"Organizing Modules" on page 214 presents a conventional technique for using modules called the interface/implementation model. This model can be used to create larger networks of modules. It allows modules to be managed without the need for complex use relationships. If your program contains only a single module, and you do not intend for the code to be usable by others, you can skip this section and go on to the next.
"Storing Modules" on page 222 discusses how to structure your ScriptX program so that it can be saved more easily. Without modules, you must individually store each class and object that your program uses, and you must also reconstruct any global variables that the program requires. By encapsulating the program within a module, classes, objects, functions, and global variables in the program are automatically saved for you.
This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.