|
|
Section Intro: Alists
AlistsSynopsis:Meta-HTML provides a textual way to manipulate complex data structures which would (in normal use) be stored in packages. The textual representation of a package is called an alist, which is short for association list, and which is a construct well known to Lisp and Scheme programmers. An alist consists of name and value pairs, surrounded by parentheses, with the entire set of name and value pairs also parenthesized. Functions exist to create alists from scratch, to modify the variable settings within an alist, to create an alist from the contents of a package, and to populate a package with the contents of an alist. Commands:
More Information: Association lists are an efficient and extensible way to hold on to complex data structure across invocations of Meta-HTML, akin to printing out and reading back in complex C structure. Fortunately, you don't have to do the parsing of the association list yourself, since Meta-HTML provides that functionality for you.
DEFault the value of the VARiable named by NAME to VALUE, in the association list referenced by ALISTVAR.
Return the value of the NAMEs given from the association list
specified by ALISTVAR. Each NAME is a
variable name which has had a value assigned to it with The values are returned in the order in which the NAMEs appear.
Merge the alists stored in the passed variable names into a single alist, and return that new alist. By default, each ALIST-VAR encountered overrides values set in previous alists that were encountered -- the values do not "pile up" -- they instead replace each other. Passing the keyword argument APPEND=TRUE changes this behavior; in this case values seen in subsequent alists are appended to the values in previous alists, creating array variables in the output. <set-var a1=<make-alist foo=foo1 bar=bar1>
a2=<make-alist foo=foo2 newvar=newval>>
<alist-merge a1 a2>
<alist-merge a1 a2 append=true>
produces:
(("BAR" . "bar1")("FOO" . "foo2")("NEWVAR" . "newval"))
(("BAR" . "bar1")("FOO" "foo1" "foo2")("NEWVAR" . "newval"))
For each variable in the association list within ALISTVAR, remove the variable from the association list if it is prefixed with one of the specifed package names. For example, given that the variable ALIST contained the alist:
(("FOO::BAR" . "bar") ("FOO::BAZ" . "baz") ("BAR::X" . "val"))
then calling:
<alist-package-delete alist foo> <get-var-once alist> produces:
(("BAR::X" . "val"))
Return a newline separated list of all of the packages which are defined within the association list stored within ALISTVAR. Because the list is newline separated, the result can easily be assigned to an array variable:
Returns a newline separated list of the fully qualified variable names found in the alist named by ALISTVAR 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 alist=<make-alist this::foo=bar this::bar=baz>> <set-var names[]=<alist-package-vars alist>> <get-var-once names[1]> is <alist-get-var alist <get-var-once names[1]>>produces: THIS::FOO is bar
Gives the variable NAME the value of VALUE in the association list specified by ALISTVAR. Any number of name/value pairs may be given, and whitespace is not significant. Where =VALUE is omitted, the value is the empty string.
<alist-set-var myalist foo=bar bar=baz> <alist-get-var myalist foo> ==> bar <alist-get-var myalist bar> ==> baz <alist-get-var myalist <alist-get-var myalist foo>> ==> baz
Takes the textual list representation of a package, and creates (or modifies) the package named by PACKAGE-NAME.
<alist-to-package <package-to-alist foo> bar>
But don't use that, of course. Use
Make NAMEs be non-existent in the association list specified by ALISTVAR.
The existence of a variable has nothing to do with its value -- a variable exists if it is present within the list, whether or not it has a value.
Return "t" if STRING is a representation of an association list.
Return an alist from the NAME-VALUE pairs passed. <make-alist foo=bar baz=this>produces: (("BAZ" . "this")("FOO" . "bar"))
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> <p> The contents of Foo: <package-to-alist foo> The stripped contents: <package-to-alist foo strip=true>produces:
Edit Section
![]() The META-HTML Reference Manual V2.0 Copyright © 1995, 1998, Brian J. Fox Found a bug? Send mail to bug-manual@metahtml.org |