pTAL Guidelines for TAL Programmers
Differences Between TAL and pTAL
pTAL Guidelines for TAL Programmers—527256-002
3-4
Address-Type Variables
Address-Type Variables
In pTAL and in D40 and later releases of TAL, you can declare variables whose data
type is an address type. The address types are shown in Table 2-1 on page 2-11.
Example 3-2 on page 3-4 has a declaration for each of the address types and
examples of how you might use them. Both TAL and pTAL recognize these address-
type declarations but:
•
TAL does not enforce the variable’s address type when the variable is used in
expressions or in address conversion routines. D40 TAL does not report any errors
for Example 3-2 on page 3-4.
•
pTAL enforces each variable’s type when the variable is used in an expression.
Example 3-2. Address-Type Variables
BADDR b;
WADDR w;
EXTADDR e;
SGBADDR sgb;
SGWADDR sgw;
SGXBADDR sgxb;
SGXWADDR sgxw;
PROCADDR p;
CBADDR c1;
CWADDR c2;
PROCPTR pptr(i, j);
INT i, j;
END PROCPTR;
PROC r(a, b);
INT a, b;
BEGIN
...
END;
PROC pp;
BEGIN
WADDR w1 := 8;
INT i;
i := w; ! Error in pTAL: cannot assign
! WADDR to INT
i := b '+' 3; ! Error in pTAL: cannot assign
! BADDR to INT
b := 6;
w := $BADDR_TO_WADDR(b);
w := $BADDR_TO_WADDR(w1); ! Error in pTAL: argument to
! $BADDR_TO_WADDR must be BADDR
@pptr := p;
@pptr := @r;
END;