Frank Heckenbach wrote:
The type-cast model GPC follows (or rather, aims to) is the one of BP (the only one I know) which is as follows:
Expressions can be cast between ordinal and pointer types. In this case, the result of the type-cast is no "lvalue" (can't be assigned to etc.), and the ordinal value (extended to pointers) is preserved.
"Lvalues" (the BP manual speaks of variable type casts here, but in fact it allows it also for things like `foo^', i.e. any lvalue) can be cast to a type whose size matches. (Of course, this is a portability issue, which BP doesn't care about, so it's up to the user to make sure that the size matches, e.g. casting something of type `Foo' to `array [1 .. SizeOf (Foo)] of Byte', or in the example above using `BitSizeOf (Double)' instead of 64.) In this case, the bit pattern is preserved, and the result is also an lvalue, i.e. can be used on both sides of an assignment etc.
There is the case of variable type casts of typeless var parameters (i.e. without a size match).
Regards,
Adriaan van Os