| THE META-HTML LANGUAGE REFERENCE MANUAL

Arrays | [TOC] | Flow Control

## Section Intro: Packages

Synopsis:

Packages are repositories which contain symbols and their values.

Each time a symbol is referenced, a package must first be found, and then the symbol may be found within that package. You indicate which package to look the symbol up in by supplying a package prefix. When the prefix is not supplied, the symbol is looked up in the current package.

Commands:

%%read-package-file %%write-package-file alist-to-package | in-package package-delete package-names | package-to-alist package-vars

More Information:

For example, a full reference to the symbol BAR stored in the FOO package looks like:

       FOO::BAR

There are very few commands specifically for dealing with packages, because most of the operations are performed implicitly, rather than explicitly. To create a package, simply give the package name as part of the symbol, in the place where the symbol is normally used.

       <set-var foo::bar = "Hello">

This has the effect of creating the package FOO if it didn't already exist.

### Function Documentation

`<%%read-package-file FILENAME>` | Simple

Reads packages from FILENAME. FILENAME should contain the binary representation of packages that were written out with `%%write-package-file`, and nothing else.

Returns a number indicating the number of packages read from the file.

This is used internally by `require`.

`<%%write-package-file FILENAME [PACKAGE-NAME...]>` | Simple

Writes the binary representation of the packages specified by PACKAGE-NAMEs to the file specified by FILENAME.

Returns the number of packages written.

The packages may be read back in with `%%read-package-file`. This command is used in the `mklib` program in the Meta-HTML distribution.

`<alist-to-package ALIST PACKAGE-NAME>` | Simple

Takes the textual list representation of a package, and creates (or modifies) the package named by PACKAGE-NAME.

`<in-package PACKAGE-NAME> body </in-package>` | Complex

Evaluate BODY in an environment where variables which are not specifically prefixed with a package name are looked up and stored within PACKAGE-NAME.

The special package name `"local"` creates an anonymous package within which to work. The contents of local packages are only accessible within the expressions surrounded by the `in-package` operator.

`<package-delete PACKAGE-NAME ...>` | Simple

Remove the definition of the packages named by PACKAGE-NAME, and all of the variables defined within them.

`<package-names>` | Simple

Returns a newline separated list of the all of the named packages which are currently defined. Because the list is newline separated, the result can easily be assigned to an array variable:

      <set-var all-packages[]=<package-names>>

`<package-to-alist PACKAGE-NAME [STRIP=TRUE]>` | Simple

Returns a Lisp readable string containing the names and values of the variables in PACKAGE. If STRIP=TRUE is supplied, the package name is removed from the variables before placing them in the list. See the following code sequence:

    <set-var
      foo::bar=baz
      foo::array[0]=Elt-0
      foo::array[1]=Elt-1>
      The contents of Foo: <package-to-alist foo>
    The stripped contents: <package-to-alist foo strip=true>

produces:

    The contents of Foo: (("FOO::BAR" . "baz")("FOO::ARRAY" "Elt-0" "Elt-1")("FOO::BAZ" . "bar"))
    The stripped contents: (("BAR" . "baz")("ARRAY" "Elt-0" "Elt-1")("BAZ" . "bar"))

`<package-vars PACKAGE-NAME [STRIP=TRUE]>` | Simple

Returns a newline separated list of the fully qualified variable names found in the package named by PACKAGE-NAME. When STRIP=TRUE is supplied, the returned variable names have the package prefix stripped off, making them not fully qualified. The names are not returned in any significant order. Because the list is newline separated, the results can easily be assigned to an array variable:

    <set-var foo::bar=baz>
    <set-var foo::baz=bar>
    <set-var names[]=<package-vars foo>>
    <get-var names[1]>

produces:

    FOO::ARRAY

Edit Section
Function Index
Variable Index

The META-HTML Reference Manual V1.4 Copyright © 1995, 1996, Brian J. Fox, 1996, 1997 Universal Access Inc.
Found a bug? Send mail to bug-manual@metahtml.com