文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 外语学习 > 英语学习 > THE NAME OPERATOR OF SNOBOL
侵权投诉

THE NAME OPERATOR OF SNOBOL

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

第1页

你可能喜欢

热门文档

相关文档

  • PROGRAM DEFINED OPERATORS OF SNOBOL

    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

    INDIRECT REFERENCE OF SNOBOL_英语学习_外语学习_...The unary operator dollar sign ($) is the "in...An invalid state name would reference a new ...

  • UNEVALUATED EXPRESSIONS OF SNOBOL

    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 ...

  • SIMPLE OPERATORS OF SNOBOL

    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

    IMMEDIATE ASSIGNMENT OF SNOBOL Our examples have made extensive use of the conditional assignment operator to capture matched substrings after a successful ...

  • ARRAYS OF SNOBOL

    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 DEFINED DATA TYPES OF SNOBOL_英语学习_外语学习_教育专区。PROGRAM ...the place of the function name, and the field names replacing the ...

  • 07_Operator+Overload

    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&...

  • 2013_C _4_Operator_overloading

    Function Definition ostream& operator<< (ostream& osObject, const className &cobject) { // output the members of cobject return osObject; private: double...

  • CAPTURING MATCH RESULTS OF SNOBOL

    CAPTURING MATCH RESULTS OF SNOBOL_英语学习_外语学习_教育专区。CAPTURING ...The operator is called conditional, because assignment occurs ONLY if the ...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email