<<<<<<<<<<<<<<<<<

arg_procedure(prog_tools) Library_Name arg_procedure(prog_tools)

NAME

arg_procedure - a lymb procedure object with argument handling

DESCRIPTION

The arg procedure object is designed to support code packaging similar to functions in C. By default, objects created within an arg_procedure are local and will be freed once the procedure call is complete. Arguments are passed to the arg_procedure using an instance of the arg_vector object. Once inside of the arg_procedure this object is called args.

SUPERCLASS

object

MESSAGES

in_args=(arg1,arg2,...) Sets the arguments that will be on the stack when the procedure is called.

call_actions= LYMB statements Sets the body of the procedure. This is where you do the work. If you need to create global objects, use the enable_globals! method of msg.

call! Executes the body of the procedure.

call:(arg1, arg2,...) A combination of in_args= and call!. Calls the arg_procedure with the arguments specified.

meta_call:(arg1,arg2,...) Just like call: except that the first argument is assumed to be an object. A reference to this object is created and called self. This argument is not included in the in_args. This method is primarily used by metaclasses.

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.

EXAMPLE

The following arg_procedure recursively computes the factorial of its input argument.

arg_procedure new: `fact' call_actions=`

/* create some local variables */ scalar new: `i'; scalar new: `temp'; logic new: `l1'; loop new: `loop1'; arg_vector new: `results';

loop1 resolution= 1 duration= [args dimension?] tick_actions= ` i = [args @ [temp = [loop1 time?] + 1 ?] scalar_args?]; l1 less:(i,2) false:` i - 1; fact call: i; i + 1; i * [fact return_value?]; results components+ i; ' true:` results components+ 1; ' ; ' start! ;

/* now set the return values */ fact return_value= [results components?]; ' ;

fact call: (1,2,3,4,5) print: return_value;

SEE ALSO

arg_vector procedure metaclass


Please send comments and suggestions to
consult@rpi.edu