Stand-Alone Routine Implementations



next up previous contents index
Next: Parameterized Implementations Up: Implementations Previous: Modules

Stand-Alone Routine Implementations

The implementation of a stand-alone routine has the form:
        <routine_def> -> <routine_interface> <body> end <idn> 
        <routine_interface> -> <proc_interface> | <iter_interface>
The final idn in the routine_def must match the routine name introduced by the name of the routine.

A routine implementation is a scope in which the idns that name the formal parameters and formal arguments are defined. These names can be used in the routine body to refer to the respective parameters and arguments. Theta uses call-by-sharing (6.2) to pass arguments to a routine. Accordingly, making an assignment to a formal argument does not affect the caller; it only changes what object is denoted by that formal. The only way a procedure or iterator can communicate with its caller is by returning results (yielding results for an iterator), signaling exceptions, or modifying mutable argument objects.

If control reaches the end of the body of a procedure that has results, the procedure will terminate with the exception "failure(no return results)". Iterators, and procedures without return results, can terminate normally by reaching the end of their bodies.



theta-questions@lcs.mit.edu