Improving the control structure of SNOBOL4

In a recent issue of SIGPLAN Notices (3), Ralph Griswold proposed a set o f radical modifications to SNOBOL4 to improve its overall structure, Thes e revisions, while good as far as they go, do not treat adequately the problems of function definition, My purpose in this note is to suggest a better treatment of function definition, My ideas arise partly from m y experience in using SNOBOL4 to write a moderately-large (500 statements) parser-generator (1) , A SNOBOL4 function definition has two components : a sequence of statement s defining the function, and a call on the primitive function DEFINE to specif y the starting statement of the definition, its parameters, and its loca l variables, For example, the SNOBOL4 manual (2) gives an example of a function REVERSE to reverse a string, It becomes defined when the statemen t DEFINE('REVERSE(STRING) ONECH,CH' , 'R1') is executed, and its definition is given by the sequence of statement s Rl ONECH = LEN(l) , C H R2 STRING ONECH = :F(RETURN) REVERSE = CH REVERSE :(R2) Here ONECH and CH are local variables of the definition , Function evaluation commences with the transfer to the function label , and terminates with the execution of a goto to RETURN, FRETURN, or NRE TURN , Consequently, labels must be unique throughout a program ; there is no wa y to construct labels that are local to a particular function definition , There are two freedoms provided here that in my experience are of no valu e whatsoever, First, the function definition is made dynamically at ru n time rather than statically at compile time, Second, there are no conventions governing the placement of the DEFINE call or of the definin g statements ; in fact, the defining statements need not be segregated a t all, but may be mixed in with, or even part of, the remainder of the program , The uselessness of these freedoms is demonstrated by the examples given i n (2), all of which follow the same pattern of function definition : a grou p of DEFINE calls at the head of the program and a group of defining statement s at the end of the program,