Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
ALGOL 68
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Coercions: casting=== The [[Implicit type conversion|coercions]] produce a coercee from a coercend according to three criteria: the a priori mode of the coercend before the application of any coercion, the a posteriori mode of the coercee required after those coercions, and the syntactic position or "sort" of the coercee. Coercions may be cascaded. The six possible coercions are termed ''deproceduring'', ''dereferencing'', ''uniting'', ''widening'', ''rowing'', and ''voiding''. Each coercion, except for ''uniting'', prescribes a corresponding dynamic effect on the associated values. Hence, many primitive actions can be programmed implicitly by coercions. Context strength β allowed coercions: * soft β deproceduring * weak β dereferencing or deproceduring, yielding a name * meek β dereferencing or deproceduring * firm β meek, followed by uniting * strong β firm, followed by widening, rowing or voiding ==== Coercion hierarchy with examples ==== ALGOL 68 has a hierarchy of contexts which determine the kind of coercions available at a particular point in the program. These contexts are: {|class="wikitable" !rowspan=2 {{verth|va=middle|Context}} !rowspan=2| Context location !colspan=5| Coercions available !rowspan=2| Coercion examples in the context |- style="text-align:center" |bgcolor="#5555ff" style="color:#ffffff;" {{verth|va=middle|{{white|'''Soft'''}}}} |bgcolor="#00ee00" style="color:#ffffff;" {{verth|va=middle|{{white|'''Weak'''}}}} |bgcolor="#dddd00" style="color:#000000;" {{verth|va=middle|{{black|'''Meek'''}}}} |bgcolor="#cc8800" style="color:#ffffff;" {{verth|va=middle|{{white|'''Firm'''}}}} |bgcolor="#bb0000" style="color:#ffffff;" {{verth|va=middle|{{white|'''Strong'''}}}} |- |bgcolor="#bb0000" style="color:#ffffff;" {{verth|va=middle|{{white|'''Strong'''}}}} |Right hand side of: * Identity-declarations, as "~" in: <code>'''REAL''' x = ~</code> * Initialisations, as "~" in: <code>'''REAL''' x := ~</code> Also: * Actual-parameters of calls, as "~" in:<code>'''PROC''': sin(~)</code> * Enclosed clauses of casts, as "~" in: <code>'''REAL'''(~)</code> * Units of routine-texts * Statements yielding '''VOID''' * All parts (but one) of a balanced clause * One side of an identity relation, as "~" in: <code> ~ '''IS''' ~</code> |bgcolor="#5555ff" style="color:#ffffff;" rowspan=4 width="50px" {{verth|va=middle|{{white| deproc​edur​ing}}}} |bgcolor="#00ee00" style="color:#ffffff;" rowspan=3 width="50px" {{verth|va=middle|{{white| All '''SOFT''' then weak derefer​encing (deref​erencing or deproc​eduring, yield​ing a name)}}}} |bgcolor="#dddd00" style="color:#000000;" rowspan=2 width="50px" {{verth|va=middle| {{black|All '''WEAK''' then derefer​enc​ing (deref​erenc​ing or deproc​edur​ing)}}}} |bgcolor="#cc8800" style="color:#ffffff;" rowspan=1 width="50px" {{verth|va=middle|{{white| All '''MEEK''' then unit​ing}}}} |bgcolor="#bb0000" style="color:#ffffff;" width="50px" {{verth|va=middle|{{white| All '''FIRM''' then widen​ing, rowing or voiding}}}} |colspan=1 bgcolor="#bb0000" style="color:#ffffff;"| Widening is always applied in the '''INT''' to '''REAL''' to '''COMPL''' direction, provided the modes have the same size. For example: An '''INT''' will be coerced to a '''REAL''', but not vice versa. Examples: * to '''REAL''' from '''INT''' * to '''COMPL''' from '''REAL''' * to []'''BOOL''' from '''BITS''' * to []'''CHAR''' from '''BYTES''' A variable can also be coerced (rowed) to an array of length 1. For example: * to [1]'''INT''' from '''INT''' * to [1]'''REAL''' from '''REAL''' etc. |- |bgcolor="#cc8800" style="color:#ffffff;" {{verth|va=middle|{{white|'''Firm'''}}}} || *Operands of formulas as "~" in:<code>~ '''OP''' ~</code> *Parameters of transput calls |colspan=3 bgcolor="#cc8800" style="color:#ffffff;"| Example: <code>'''UNION'''('''INT''','''REAL''') var := 1</code> |- |bgcolor="#dddd00" style="color:#000000;" {{verth|va=middle|{{black|'''Meek'''}}}} || * Trimscripts (yielding '''INT''') * Enquiries: e.g. as "~" in the following <code>'''IF''' ~ '''THEN''' ... '''FI'''</code> and <code>'''FROM''' ~ '''BY''' ~ '''TO''' ~ '''WHILE''' ~ '''DO''' ... '''OD''' etc</code> * Primaries of calls (e.g. sin in sin(x)) |colspan=4 bgcolor="#dddd00" style="color:#000000;"|Examples: * to '''BOOL''' from '''REF''' '''REF''' '''BOOL''' * to '''INT''' from '''REF''' '''REF''' '''REF''' '''INT''' |- |bgcolor="#00ee00" style="color:#ffffff;" {{verth|va=middle|{{white|'''Weak'''}}}} || * Primaries of slices, as in "~" in: <code>~[1:99]</code> * Secondaries of selections, as "~" in: <code>value '''OF''' ~</code> |colspan=5 bgcolor="#00ee00" style="color:#ffffff;"|Examples: * to '''REF''' '''INT''' from '''REF''' '''REF''' '''INT''' * to '''REF''' '''REAL''' from '''REF''' '''REF''' '''REF''' '''REAL''' * to '''REF''' '''STRUCT''' from '''REF''' '''REF''' '''REF''' '''REF''' '''STRUCT''' |- |bgcolor="#5555ff" style="color:#ffffff;" {{verth|va=middle|{{white|'''Soft'''}}}} || The LHS of assignments, as "~" in: <code>~ := ...</code> |colspan=6 bgcolor="#5555ff" style="color:#ffffff;"| Example: * deproceduring of: <code>'''PROC''' '''REAL''' random: e.g. random</code> |} For more details about Primaries, Secondaries, Tertiary & Quaternaries refer to [[#Dyadic operators with associated priorities|Operator precedence]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)