THE NAME OPERATOR OF SNOBOL
The unary name operator provides the address or location in memory where a variable is stored. Its graphic symbol is the period (.). We'll introduce it here through an example.
Consider the indirect reference operator mentioned earlier. Suppose we want to use a variable to point to different elements of an array or table. If we try the following, we immediately discover a problem:
? A = ARRAY('10,10')
? A[4,2] = 'DOG'
? V = 'A[4,2]'
? OUTPUT = $V
Success
The indirect reference operator treats the string 'A[4,2]' as a variable name, rather than an array element. Remember, any character sequence can be used indirectly to create a variable. SNOBOL4 creates a variable called A[4,2] that has absolutely no connection with array A. The fact that this character sequence happens to look like an array reference to us is purely coincidental from SNOBOL4's point of view.
To make this work, the name operator is applied to A[4,2] to obtain the address of that array element. The address can be stored in variable V, and referenced with the indirect operator:
? V = .A[4,2]
? OUTPUT = $V
DOG
The name operator provides a general method for specifying the name of an object. Both of these statements are correct for specifying the first argument to the INPUT function:
INPUT('INFILE', 1, , 'CAPITAL.DAT')
INPUT(.INFILE, 1, , 'CAPITAL.DAT')
Either form, 'INFILE' or .INFILE, tells the INPUT function the name of the variable to be input associated. However, using the name operator allows us to associate a file with an array or table element: INPUT('A[4,2]', 1, , 'CAPITAL.DAT') (incorrect)
INPUT(.A[4,2], 1, , 'CAPITAL.DAT')
Note that alternate use of the indirect reference and name operators "cancel" one another, so
? OUTPUT = $(.($(.A[4,2])))
DOG
but SNOBOL4 will use the specified function whenever the operator must be...The general form of OPSYN is: OPSYN(new name, old name, i) The new ...
INDIRECT REFERENCE OF SNOBOL_英语学习_外语学习_...The unary operator dollar sign ($) is the "in...An invalid state name would reference a new ...
The current value of N is ignored at this time. Later, when NPAT is used in a pattern match, the unevaluated expression operator tells SNOBOL4 to ...
SNOBOL4 has a very simple rule for determining if an operator is binary or unary: Unary operators are placed immediately to the left of their operand....
IMMEDIATE ASSIGNMENT OF SNOBOL Our examples have made extensive use of the conditional assignment operator to capture matched substrings after a successful ...
They allow a single variable name to specify more than one data element; ...SNOBOL4 takes the idea one important step further, with the concept of ...
PROGRAM DEFINED DATA TYPES OF SNOBOL_英语学习_外语学习_教育专区。PROGRAM ...the place of the function name, and the field names replacing the ...
Use the name + in place of the name of a function name ? Use keyword operator in front of the + ? Example: friend Circle operator+(const Circle&...
Function Definition ostream& operator<< (ostream& osObject, const className &cobject) { // output the members of cobject return osObject; private: double...
CAPTURING MATCH RESULTS OF SNOBOL_英语学习_外语学习_教育专区。CAPTURING ...The operator is called conditional, because assignment occurs ONLY if the ...
热门文档