The previous chapter gave several examples of procedure definitions, in connection with the "rooms" database. These are all examples of imperatives. Each of those imperatives implicitly declared a new global variable, the name of the procedure, and assigned a procedure to it.
As an example, here is the definition of a silly little procedure called `silly' which takes one thing as input and then prints it out twice using the print-arrow:
define silly(item); item => item => enddefine;This contains an implicit global declaration of `silly' as the name of a variable, whose initial value is the procedure defined here. I.e. a procedure definition is like a declaration that includes an initialisation. Just as we can use a declaration to initialise a variable to refer to a list, as in
vars people = [mary tom suzy dick];so we can use the form
vars <name> = procedure ..... endprocedure;to initialise a variable to refer to a procedure. The full syntax for this will not be explained till later. The main thing for now is to point out that the above definition of "silly" could be re-written as follows, using the syntax "procedure ... endprocedure" to form an expression that refers to a procedure without naming it:
vars silly = procedure (item); item => item => endprocedure; ;;; Now test it silly([the cat]); ** [the cat] ** [the cat]However if silly is defined this way it will not have a name as part of the procedure, so printing it will not give its name:
silly => ** <procedure>We can give it a name using the updater of "pdprops", thus
[silly] -> pdprops(silly); silly => ** <procedure silly>Note that the pdprops can be a list in which case only the first item will be used as the name. Other information associated with the procedure can be stored in the list. If no further information is needed then the name can simply be a word:
"silly" -> pdprops(silly); silly => ** <procedure silly>What the "define silly(item); ... enddefine" syntax does is equivalent to the above initialised declaration plus storing the word as the name of the procedure. See also HELP PDPROPS, and REF PDPROPS