previous next top contents index framed top this page unframed
Figure 33–27. displace (GENERIC)
| $BUILTIN ADDRESS PROCEDURE displace (POINTER p; INTEGER n); $BUILTIN ADDRESS PROCEDURE displace (POINTER p; LONG INTEGER n); $BUILTIN ADDRESS PROCEDURE displace (ADDRESS a; INTEGER n); $BUILTIN CHARADR PROCEDURE displace (CHARADR c; INTEGER n); $BUILTIN ADDRESS PROCEDURE displace (ADDRESS a; LONG INTEGER n); $BUILTIN CHARADR PROCEDURE displace (CHARADR c; LONG INTEGER n); |
displace computes an ADDRESS or CHARADR as a displacement from a POINTER, ADDRESS, or CHARADR.
The ADDRESS forms return an ADDRESS that is displaced n storage units from a. No rounding or alignment occurs.
The POINTER forms return an address that is displaced n storage units from p (i.e., displace(p,n) is equivalent to displace(cva(p),n)).
The CHARADR forms return a CHARADR that is displaced n characters from c.
n may be positive or negative. If the resulting ADDRESS or CHARADR would be less than the lowest representable ADDRESS or CHARADR, or greater than the highest representable ADDRESS or CHARADR, the result is undefined; i.e., a program may not assume that ADDRESSes “wrap around” at Zero.
A garbage collection cannot occur during a call to displace.
Example 33–28. Use of displace
| INTEGER i; STRING s; CHARADR c; s := "xyz"; c := displace(cvc(s),2); i := cLoad(c); # i is 'z' |
MAINSAIL Language Manual, Section 33.28