out_args= (arg1,arg2,...) Declares the names of the objects to be modified from the out_formals of the procedure at the end of the next call! message. All out_args must exist at the time the call! message is sent. The out_args will need to be set each time a call! message is sent, as they are overridden on recursive calls to the procedure.
ref_args= (arg1,arg2,...) Declares the names of the objects to be passed by reference to the procedure.
in_formals= (formal1,formal2,...) Declares the names of the input parameters as they are referred to in the procedure's call_actions.
out_formals= (formal1,formal2,...) Declares the names of the output parameters as they are referred to in the procedure's call_actions.
ref_formals= (arg1,arg2,...) Declares the names of the by-reference parameters as they are referred to in the procedure's call_actions.
call_actions= LYMB statements defines the body of the procedure.
call_actions+ LYMB statements appends statements to the body of the procedure.
return_value=(val1,val2,...) associates a list of values with the return value of the procedure. These can be set from anywhere, although they will most often be set from inside the procedure's call_actions.
return_value? returns the current return value(s) of the procedure.
break! stop parsing the call_actions block after completion of the current group of LYMB staments.
call! Executes the call_actions of the procedure. Before the actions are executed, a new symbol table is pushed on the symbol table stack and it is populated by executing (effectively) "arg new: formal;" for each in_arg/in_formal and out_arg/out_formal pair. After the actions are executed, any output arguments object pointers are swapped with their corresponding output formal object pointer (which may have been destroyed and recreated during the call_actions). The symbol table is then freed, implicitly freeing all in_formals, local objects created by the call_actions, and now defunct out_args.
procedure new: `fact' in_formals=(`i') call_actions=` logic new! less:(i,2) false:` i - 1; fact in_args=(`i') call!;
i + 1; i * [fact return_value?]; fact return_value= i; ' true:` fact return_value= 1; ' free! ; ' ;
The following procedure creates a motif_label that will exist beyond the scope of the procedure call. The name is generated using a string object thats life is limited to the life of the procedure call. The name of the motif_label is available to the caller using the procedure's return_value? message.
procedure new: `create_label' ref_formals=(`parent', `index') call_actions=` string new: name float_format= `label_0.000' = index; msg enable_globals!; motif_label new: name parent= parent create!; create_label return_value= name; ' ;
Internally, each ref_formal is represented by a reference object. Instances of the reference class forward all messages except does_not_understand, name=, free!, and referent= to the objects they reference.