Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

QUIT

Draft MDC Standard

8.2.26 Quit

Q[UIT] postcond


[ SP ]
SP expr
SP @ expratom V expr



Quit terminates execution of an argumentless Do command, doargument, xargument, exfunc, exvar, or For command.

Encountering the end-of-routine mark eor is equivalent to executing an unconditional argumentless Quit command.

The effect of executing a Quit command in the scope of a For command is fully discussed in 8.2.13. Note the eor never occurs in the scope of a For command.

If an executed Quit command is not in the scope of a For command, then it is in the scope of some argumentless Do command, doargument, xargument, exfunc, or exvar if not explicitly then implicitly, because the initial activation of a process, including that due to execution of a jobargument, may be thought of as arising from execution of a Do command naming the first executed routine of that process.

The effect of executing a Quit command in the scope of an argumentless Do command, doargument, xargument, exfunc, or exvar is to restore the previous variable environment (if necessary), restore the value of $Test (if necessary), restore the previous execution level, and continue execution at the location of the invoking argumentless Do command, doargument, xargument, exfunc, or exvar.

If an expr is present in the Quit command and the return is not to an exfunc or exvar, an error condition occurs with ecode = "M16". If the expr is not present and the return is to an exfunc or exvar, an error condition occurs with ecode = "M17".

The following discussion uses terms defined in the Variable Handling (see 7.1.2.2) and Process-Stack (see 7.1.2.3) models and, like those subclauses, does not imply a required implementation technique.

Execution of a Quit command occurs as follows:

  1. If an expr is present, evaluate it. If the resulting value is a value of data type OREF, do not coerce this value into a value of data type MVAL. This value becomes the value of the invoking exfunc or exvar.
  2. Remove the frame on the top of the PROCESS-STACK. If no such frame exists, then execute an implicit Halt.
  3. If the PROCESS-STACK frame’s linked list of CONTEXT-STRUCTUREs contains New NAME-TABLEs, process them in last-in-first-out order from their creation. If the CONTEXT-STRUCTURE is exclusive, make all entries in the currently active local variable NAME-TABLE point to empty DATA-CELLs. In all cases, the New NAME-TABLEs are copied to the currently active NAME-TABLEs. Note that, in the model, Quit never encounters any restart CONTEXT-STRUCTUREs in the linked list because they must have been removed by TCommits or ROLLBACKs for the Quit to reach this point in its execution.
  4. If the frame contains formal list information:
    1. Extract the formallist and process each name in the list with the following steps:
      1. Search the NAME-TABLE for an entry containing the name. If no such entry is found, processing of this name is complete. Otherwise, proceed to step ii.
      2. Delete the NAME-TABLE entry for this name.
    2. Finally, copy all NAME-TABLE entries from this frame into the NAME-TABLE.
    3. Processing of this frame is complete, continue at step b.
  5. If the frame is a TStart frame and $TLevel is greater than zero, Quit generates an error with ecode = "M42". If the frame is a TStart frame and $TLevel is zero, then the frame is discarded.
  6. If the frame is from an exfunc or exvar or from an argumentless Do command, set the value of $Test to the value saved in the frame. However, if this location is in a routine which has been modified or made inaccessible by the execution of a RSave command (subsequent to the placing of the frame on the PROCESS-STACK), unspecified behavior may result.
  7. Restore the execution level and continue execution at the location specified in the frame.
Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.

Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.

This page most recently updated on 15-Nov-2023, 14:46:53.

For comments, contact Ed de Moel (demoel@jacquardsystems.com)