[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The bitwise operators `shl', `shr', `and', `or', `xor' and `not' work in GNU Pascal like in Borland Pascal. As an extension, you can use them as procedures, for example
program AndProcedureDemo; var x: Integer; begin and (x, $0000ffff); end. |
as an alternative to
program AndOperatorDemo; var x: Integer; begin x := x and $0000ffff; end. |
GPC accepts the BP style notation `$abcd' for hexadecimal numbers, but you also can use Extended Pascal notation:
program EPBaseDemo; const Binary = 2#11111111; Octal = 8#177; Hex = 16#ff; begin end. |
and so on up to a basis of 36. Of course, you can mix the notations as you like, e.g.:
program BPEPBaseDemo; begin WriteLn ($cafe = 2#1100101011111110) end. |
`Inc' and `Dec' are implemented like in Borland Pascal. `Pred' and `Succ' are generalized according to Extended Pascal and can have a second (optional) parameter:
procedure SuccDemo; var a: Integer = 42; begin a := Succ (a, 5); WriteLn (a) { 47 } end. |
BP style `absolute' variables work in the context of overloading other variables as well as in the context of specifying an absolute address, but the latter is highly unportable and not very useful even in Dos protected mode.
program BPAbsoluteDemo; |
GNU Pascal knows Borland Pascal's procedures FillChar
and
Move
. However, their use can be dangerous because it often
makes implicit unportable assumptions about type sizes, endianness,
internal structures or similar things. Therefore, avoid them
whenever possible. E.g., if you want to clear an array of strings,
don't `FillChar' the whole array with zeros (this would
overwrite the Schema discriminants, see section 8.14.15 BP compatibility: Strings), but rather
use a `for' loop to assign the empty string to each string. In
fact, this is also more efficient than `FillChar', since it
only has to set the length field of each string to zero.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |