Category:ALGOL 68: Difference between revisions
Content added Content deleted
m (→Grammar: http://www.softwarepreservation.org/projects/ALGOL/book/Lindsey_van_der_Meulen-IItA68-Revised-SyntaxOnly.pdf/view) |
(→Coercion (casting): more details) |
||
Line 143: | Line 143: | ||
ALGOL 68 has a hierarchy of contexts which determine which kind of |
ALGOL 68 has a hierarchy of contexts which determine which kind of |
||
coercions are available at a particular point in the program. These contexts are: |
coercions are available at a particular point in the program. These contexts are: |
||
{|class="wikitable" |
|||
⚫ | |||
! Context name !! Coercions applied in this context !! Context location !! Coercion examples |
|||
* weak - dereferencing or deproceduring, yielding a name |
|||
|- |
|||
* meek - dereferencing or deproceduring |
|||
⚫ | |||
* firm - meek, followed by uniting |
|||
|| The LHS of assignments, as in: <lang algol68>:=</lang> |
|||
⚫ | |||
|| |
|||
* deproceduring of: <lang algol68>PROC REAL random: e.g. random</lang> |
|||
Depending on the context a MODE (type) will be coerced (widened) to another type if there is no loss |
|||
|- |
|||
⚫ | |||
|weak || all ''soft'' above then weak dereferencing |
|||
coerced to a LONG REAL. But not vice-versa. Examples: |
|||
|| |
|||
⚫ | |||
* Primaries of slices |
|||
⚫ | |||
* Secondaries of selections, as in: <lang algol68>OF</lang> |
|||
⚫ | |||
|| |
|||
⚫ | |||
<lang algol68>REF REF REF INT to REF INT</lang> |
|||
|- |
|||
|meek |
|||
|| all ''weak'' above then dereferencing |
|||
|| |
|||
* Trimscripts (yielding INT) |
|||
* Enquiries: e.g. "~" in the following<lang algol68>IF ~ THEN ... FI</lang> and <lang algol68>FROM ~ BY ~ TO ~ WHILE ~ DO ... OD etc</lang> |
|||
* Primaries of calls (e.g. sin in sin(x)) |
|||
|| |
|||
⚫ | |||
|- |
|||
|firm || all ''meek'' then uniting |
|||
|| |
|||
*Operands of formulas |
|||
*Parameters of transput calls |
|||
|| e.g. <lang algol68>UNION(INT,REAL) var := 1</lang> |
|||
|- |
|||
||strong |
|||
⚫ | |||
||Right hand side of: |
|||
* Identity-declarations :=: |
|||
* Initialisations |
|||
Also: |
|||
* Actual-parameters of calls |
|||
* Enclosed clauses of casts |
|||
* Units of routine-texts |
|||
* Statements yielding VOID |
|||
* All parts (but one) of a balanced clause |
|||
* One side of an identity relation |
|||
⚫ | |||
<lang algol68>INT to LONG INT |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
A variable can also be coerced (rowed) to an array of length 1. For example: |
A variable can also be coerced (rowed) to an array of length 1. For example: |
||
<lang algol68>INT to [1]INT |
|||
REAL to [1]REAL</lang> etc |
|||
|} |
|||
Pointers are followed (dereferenced), For example: |
|||
For more details about Primaries and Secondaries refer to [[Operator_precedence#ALGOL_68|Operator precedence]]. |
|||
⚫ | |||
== Code Specimen == |
== Code Specimen == |
||
{{language programming paradigm|Concurrent}} |
{{language programming paradigm|Concurrent}} |