发布日期: 08/07/2020

Rules for Resolving Names

JMP interprets object names using name resolution. The following rules are applied sequentially to unscoped names:

1. If the variable is followed by a pair of parentheses ( ), look it up as a function.

2. If the variable is prefixed by : scope operator or an explicit data table reference, look it up as a data table column or table variable.

3. If the variable is prefixed by :: scope operator, look it up as a global variable.

4. If the variable is an explicit scope reference (such as group:vowel), look it up in the user-defined group namespace.

5. If the variable is in a Local or Parameter function, look it up as a local variable. If it is nested, repeat until a function call boundary is found.

6. If the variable is in a user-defined function or method, look it up as a function or method argument or local variable.

7. Look the variable up in the current scope and its parent scope. Repeat until the Here scope is encountered.

8. Look the variable up as a variable in the Here scope.

9. Look the variable up as a global variable.

10. If Names Default to Here(1) is at the top of the script, stop looking. The scope is local.

11. Look the variable up as a data table column or table variable. Columns are preferred over table variables.

12. Look the variable up as an operator or a platform launch name (for example, Distribution, Bivariate, Chart, and so on).

13. When the name cannot be found:

If the name is used in a reference, print and error to the log.

If the name is used as the target of an assignment (as an L-value), test the following:

If the variable is preceded by :: scope operator, create and use a global variable.

If the variable is an explicit scope reference, create and use the variable in the specified namespace or scope.

If Names Default to Here(0) is at the top of the script, create a global variable.

If Names Default to Here(1) is at the top of the script, create a Here namespace variable.

Exceptions

Some names are variables that refer to an object such as a data table, data column, or platform; they are not used for getting or setting a value. These names are passed through (or interpreted literally) rather than resolved.

For function definitions, column formulas, and Nonlinear platform formulas, the scope is the same for each row in a column.

If a name is a direct reference to a column in a data table that has been closed, the name is resolved again to that column when the table is reopened.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Show( :weight << Get As Matrix ); // weight  resolves to a column name
Close( dt, NoSave );
Show( :weight << Get As Matrix ); // weight  cannot be resolved
dt = Open( "$SAMPLE_DATA/Big Class.jmp" ); // reopen data table
Show( :weight << Get As Matrix ); // weight  resolves to a column name

However, the following example does not resolve the variable to the second instance of the data table:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = Column( dt, 5); // col is Column( "weight" );
Close( dt, NoSave );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" ); // reopen data table
Show( col << Get As Matrix ); // the reference to the first data table no longer exists

The following sections describe how JMP resolves the names of data table columns. For more information about name resolution, see Advanced Scoping and Namespaces.

需要更多信息?有问题?从 JMP 用户社区得到解答 (community.jmp.com).