Multiple variables and procedures can have the same name in a program. This can be a problem when you specify a variable or procedure in an expression. To determine which variable or procedure you mean, Prism tries to resolve its name by using these rules:
It first tries to resolve the name using the scope of the current function. For example, if you use the name x and there is a variable named x in the current function or the current file, Prism uses that x. The current function is ordinarily the function at the program's current stopping point, but you can change this. See " Choosing the Current File and Function".
If this fails to resolve the name, Prism goes up the call stack and tries to find the name in the caller of the current function, then its caller, and so on, following the scoping and visibility rules of the current language.
If no match is found in any routine active on the stack, Prism searches the static and global name spaces. If no match is found, Prism prints an error.
If the name is not found in the call stack, Prism arbitrarily chooses one of the variables or procedures with the name in the source code. When Prism prints out the information, it adds a message of the form "[using qualified name]". Qualified names are discussed below.
Issue the which command to find out which variable or procedure Prism would choose; the command displays the fully qualified name, as described below.
You can override Prism's procedure for resolving names by qualifying the name.
A fully qualified name starts with a back-quotation mark (`). The symbol farthest to the left in the name is the load object, followed optionally by the file, followed optionally by the procedure, followed by the variable name. Each is preceded by a backquote (`). Examples of Prism's identifier syntax are shown in Table 2-4.
Table 2-4 Prism Identifier Syntax
Syntax |
Description |
---|---|
a |
Specifies the variable a in the current scope. An error will be reported if no variable a exists in the current scope. |
`a |
Specifies the variable a in the global scope. |
``a |
Specifies the variable a in the global or file-static scope. |
`foo.c`a |
Specifies the variable a in file foo.c. |
`foo.c`foo`a |
Specifies the a in the procedure foo in the file foo. |
`foo`a |
Specifies the variable a in function foo (if foo is active). |
`a.out`foo.c`foo`a |
Specifies the variable a in function foo in file foo.c in load object a.out. |
`a.out`foo.c`foo:line`a |
Specifies the variable a in function foo at line number line in file foo.c in load object a.out. |
`foo.x`foo.cc`Bar::print:71`dummy |
Specifies the variable dummy in member function print of class Symbol at line number 71 in file foo.cc in load object foo.x. |
"foo.c":line |
Specifies the line number line in the file foo.c. Note the use of double quotes. |
Partially qualified names do not begin with `, but have a ` in them. For example,
foo`a
In this case, Prism looks up the function name on the left first and picks the innermost symbol with that name that is visible from your current location. This is useful primarily in referring to variables in routines on the call stack.
Use the whereis command to display a list of all the fully qualified names that match the identifier you specify.
Prism assigns its own names (using the function:line syntax, where function is the function and line is the line number where the variable declaration appeared) to variables in local blocks of C code. This disambiguates variable names, in case you reuse a variable name in more than one of these local blocks.
When debugging Fortran, Prism attempts to be case-insensitive in interpreting names, but will use case to resolve ambiguities.