Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: eval Function Up: Predefined Functions and Variables Previous: String Functions


Manipulating Symbols

This section describes a group of functions which allow you to query and modify global variables in the Glish system. These functions allow access to the internals of Glish.

symbol_set and symbol_delete in particular should be used with caution. Deleting symbols with symbol_delete in a function which refers to these deleted symbols, for example, yields unexpected results. So while these functions are available, their use is discouraged; caveat emptor.

In several of these function, a string is passed as a parameter. This string represents the symbol name which is being manipulated. Record member access etc. is not possible with these functions; only global symbol names can be used.

symbol_names()
returns the names of all of the global variables which have been defined.

symbol_names(f)
if passed a function, f, which takes a single parameter and returns a boolean, applies f to each of the global variables, and returns only the names of those for which f returned T. For example:
    symbol_names( is_function )
returns the names of all of the global functions. As another example,
    symbol_names( func (x) {is_numeric(x) && ! is_const(x)} )
returns all of the numeric global variables which are not const.

symbol_value(name)
this function takes a string, and returns the value of the symbol called name. If name has more then one element, then symbol_value returns the symbol value of each as a field in a record. The field names of the record correspond to the symbol names. If the string has a single element, the value of that symbol is returned.

symbol_set(name,value)
this function assigns the Glish value value to the symbol with the name specified by the name parameter. name must be a string, and should conform to the restrictions on Glish variable names.

symbol_set(rec)
if passed a record, this function explodes the record field names into global Glish variables. That is, each field name is mapped to the global symbol that corresponds to the field name. This global symbol is then assigned the field's value.

symbol_delete(name)
this function deletes any symbol named name. Note that this is the only way const symbols can be deleted.

is_defined(name)
this function returns T if there is a symbol called name, otherwise it returns F. This is used to prevent multiple inclusion of scripts via include.


next up previous contents index
Next: eval Function Up: Predefined Functions and Variables Previous: String Functions   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15