REDUCE

4.1 Introduction

Ids or identifiers can be used in a number of different ways. Every id has a name, called its print name. Given an id, one can obtain its name in the form of a string. Conversely, given the name of an id as a string one can obtain the id itself.

Ids have a component called the property list. This list consists of pairs and ids. A pair contains two elements, the first is the name of the property, the second is the value associated with that property. An id on the property list represents a flag.

Each id also references a package, see Chapter [packages] for more information on the package system.

In PSL an id can be used simultaneously as a variable and as a name for a function. Aside from the functions described in this chapter, there are additional functions for dealing with the values associated with an id.

An id can be referenced simply by writing its name. If the name consists only of uppercase alphabetic characters, digits, or a subset of the special characters (listed below), and if the name of the id cannot be mistaken for a number, then the id can be notated by the sequence of characters in its name.

$+ - $ & ⋆ / : ; | < = > ? ^ _ { } ~ @$

An id may have uppercase letters, lowercase letters, or both in its print name. The PSL reader normally (i.e. version 4.2 and above) converts uppercase letters to the corresponding lowercase letters when reading ids. Therefore, most of the time case makes no difference when notating ids.

The conversion of letters is controlled by the functions input-case and output-case.

(input-case modus): modus expr
 
If modus equals lower, characters on input are converted to the corresponding lowercase characters. If modus equals raise, characters are raised during input. A modus NIL leaves characters unchanged. The former modus is returned. The default is lower.

(output-case modus): modus expr
 
If modus equals lower, characters on output are converted to the corresponding lowercase characters. If modus equals raise, characters are raised during output. A modus NIL leaves characters unchanged. The former modus is returned. The default is NIL.

Ids are kept in a table which is called the symbol table (or id-hash-table). Two ids are considered different if their corresponding print names are different. For example, the id whose name is ”that” is different from the id whose name is ”THAT”. The ids which name PSL functions have lowercase names. The reason you can type such names with uppercase letters is that the reader is converting uppercase letters to lowercase by default.

1 lisp> (Add1 2)  
3  
2 lisp> (input-case nil)  
lower  
3 lisp> (Add1 2)  
⋆⋆⋆⋆⋆ ‘!Add1' is an undefined function

If the user tries to use a PSL function name for a function he is defining a warning message appears.

Do you really want to redefine the system function ‘NAME'?  
(Y or N)

If the user responds ”Y”, his definition replaces the current definition. (See Chapter 9 for a description of the switch *usermode which controls the printing of this message).

There is an escape convention for notating an id whose name contains special characters. Any character which follows a ! is considered to be an ordinary character. In addition to lowercase letters, the following characters are considered special:

! " % ' ( ) . [ ] ‘ , # |

If it is not clear from the printed output, this set of characters includes both quote and accent grave. Note that if any character wthin a name is preceded by a !, then the name will not be interpreted as a number.

SUSAN % three ways to notate the same id
susan
SuSan
+$ % an id without alphabetic characters
1+ % an id whose first character is a digit
+1 % this is a number
x^2+y^2% an id which looks like an expression
!9 % the id whose name is ”9”, not the number 9