Zippy-Egoboo Home EgoWiki > Documentation > MakingZippyObjects > ZippyNamespaces EgoWiki webs:
Main | TWiki | Know | Sandbox
Documentation . { Changes | Index | Search | Go }
A reference implementation in plain Lua for Namespaces is available: zlnamespace.lua.

Namespaces are collections of fields where each collection is associated with a global variable. Namespaces may be defined with the following syntax:

Namespace{ "namespace_name";
   field = value,
}

Where "field," "value," and "namespace_name" may be replaced with the named quantities.

The fields will thereafter be available as members of the namespace as follows:

namespace_name.field

Namespaces may additionally contain placeholders indicating that the value for a field may be obtained by loading another file. These take the following form:

Namespace{ "name";
   external_field = in_file("path/to/file.lua"),
}

These fields will not be accessible until they are "required;" this may be indicated with the "Require" function:

Require(name.external_field)

If a file must be loaded to obtain the value for a required field, it will be loaded during the call to "Require."

Certain functions (for example, ActionClass and register_type) will allow a namespace to be specified as a field of the argument table:

register_type{
   name = "CharacterClass",
   namespace = Basic,
    -- ...
}

This will add the field "CharacterClass" in the already-declared namespace "Basic" with the value being the class itself.

-- ElminI - 29 Jan 2004

Topic ZippyNamespaces . { Edit | Attach | Ref-By | Printable | Diffs | r1.2 | > | r1.1 | More }
Revision r1.2 - 08 Mar 2004 - 03:39 GMT - ElminI
Parents: WebHome > MakingZippyObjects
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding EgoWiki? Send feedback.