pTAL Guidelines for TAL Programmers
Coding Guidelines
pTAL Guidelines for TAL Programmers—527256-002
2-54
USE and DROP Statements
USE and DROP Statements
Guideline: Always assume that the value of a USE variable is initially undefined.
TAL programs can rely on the ways in which USE and DROP statements use TNS
registers. Within the DO-UNTIL loop in the following example, the program executes, in
succession, a DROP statement, a USE statement, a second DROP statement, and a
second USE statement.
Although Example 2-67 on page 2-54 uses two different names for the USE
variables—i and i_prime—both i and i_prime use the same hardware stack
register.
In pTAL, the initial value of a variable named in a USE statement is undefined. pTAL
reports a warning message if you use a USE variable in an expression without first
storing a value in it.
pTAL supports the USE and DROP statements so that programs that need to allocate
a register when running as TNS processes can do so and still be source-code
compatible with pTAL; however, in general, pTAL allocates memory for and optimizes
variables declared in USE statements just as it does a variable declared INT.
RP Directive
Guideline: Avoid using code sequences that require you to use the RP directive.
pTAL does not support the RP directive.
Example 2-67. USE and DROP Statements
PROC p;
BEGIN
USE i_prime;
DO
BEGIN
DROP i_prime;
USE i; ! Allocate USE variable for local
... ! optimization
DROP i; ! Drop USE variable
...
USE i_prime; ! Reaccess value in register
END
UNTIL i_prime = 0;
END;