Free Type Conversions

In most cases there is little need to start mixing wildly differing types. However, from time to time, in particular when dealing with system level programming or when interfacing to foreign languages, rather reckless conversions have to be dealt with. To this end the cast function will convert from anything to anything. No checks are performed on the supplied values, and quite disastrous results will occur if you try to use incorrectly cast variables.

The format of cast is

    Result = cast(returndomain,Expr)

where Expr is evaluated (if it's a numerical expression), converted to returndomain type, and unified with Result.

For instance, a null string pointer (a character pointer with a value of 0; not an empty string, which is a pointer to a byte with a value of 0) can be created using:

    NullPtr = cast(string,0)

Don't try to write the resulting string, you'd most probably get a protection violation, a hung system, or at best garbage characters.

If you don't see any obvious use for cast, don't worry. It plays no part in ordinary Prolog programs.