hokey@plus5.UUCP (Hokey) (03/25/88)
Title: Extrinsic Blocks
Advocate: Hokey <hokey@plus5.com>
History: 20 Mar 88 - Submitted
Abstract:
MUMPS presently lacks common control-flow mechanisms found in many
other languages. Additionally, the "block structure" mechanism yields
its benefits only to code invoked as a subroutine; neither the
mechanism nor the benefits are available to code invoked as an
extrinsic function.
The following proposal, in conjunction with my "Implicit DO extension"
proposal, solves both of these shortcomings.
Examples:
;WHILE clause
F Q:while D $$
. ;code
;UNTIL clause
F D $$ Q:until
. ;code
;repeat until subroutine says stop
F Q:$$
() . ;code
. QUIT $S(more:0,1:1)
;WHILE with BREAK and CONTINUE
S I=0 F Q:(while!(I=-1)) S I=$$ I I=0 ;more code...
() . ;code
. QUIT $S(normal:0,break:-1,continue:1)
Proposal: (Page and section numbers are from X11/SC1/88-14)
Add to the definition of line in 3.4:
| exblkline |
Add the following definition to section 3.4:
exblkline ::= formallist ls li ... linebody
Renumber the sections:
3.2.10 Extrinsic Special Variable
3.2.11 Extrinsic Function
as:
3.2.11 Extrinsic Special Variable
3.2.12 Extrinsic Function
Add a new section:
3.2.10 Extrinsic Block
exblk ::= $$
Extrinsic blocks invoke an inner block of lines to return a
value. When an extrinsic block is executed, the current
value of $T, the current execution level, the current
execution level are saved in an exvar frame on the
process-stack, and the execution level is increased by one.
Execution continues at the first command of the next line
in the routine, which must be an exblkline having the
current execution level.
Upon return from the subroutine the value of $T and the
execution level are restored, and the value of the argument
of the QUIT command that terminated the subroutine is returned
as the value of the exblk.
Add:
exblk
to the implicit/explicit QUIT list in the second-to-last sentence of
the first paragraph of 3.6.3 and to the similar list in the second
sentence of subparagraph d in that same section.
--
Hokey