Category:ALGOL 68: Difference between revisions

m
(coercion)
m (→‎Coercion (casting): fix typos.)
Line 29:
not too much else is required.
== Coercion (casting) ==
ALGOL 68 has a hierarchy of coercionscontexts fromwhich onedetermine contextwhich tokind another.of
coercions are available at a particular point in the program. These contexts are:
* soft - deproceduring
* weak - dereferencing or deproceduring, yielding a name
Line 36 ⟶ 37:
* strong - firm, followed by widening, rowing or voiding
 
Depending on the context MODESa MODE (typestype) will be coerced (widened) to another type if there is no loseloss
of precision. For example: An INT will be coerced to a REAL, and a REAL will be
coerced to a LONG REAL. But not visa-versa. Examples:
* INT to REAL
* REAL to COMPL
* BITS to []BOOL
* BYTES to STRING
AaA variable can also be coerced (rowed) to an array of length 1. For example:
* INT to [1]INT
* REAL to [1]REAL etc
Pointers are followed (dereferenced), For example:
* REF REF REAL to REAL