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!
===op: Operators=== The programmer may define new '''[[Operator (programming)|operators]]''' and ''both'' those and the pre-defined ones may be [[overloading (programming)|overloaded]] and their priorities may be changed by the coder. The following example defines operator <code>'''MAX'''</code> with both dyadic and monadic versions (scanning across the elements of an array). '''PRIO''' '''MAX''' = 9; '''OP''' '''MAX''' = ('''INT''' a,b) '''INT''': ( a>b | a | b ); '''OP''' '''MAX''' = ('''REAL''' a,b) '''REAL''': ( a>b | a | b ); '''OP''' '''MAX''' = ('''COMPL''' a,b) '''COMPL''': ( '''ABS''' a > '''ABS''' b | a | b ); '''OP''' '''MAX''' = ([]'''REAL''' a) '''REAL''': ('''REAL''' out := a['''LWB''' a]; '''FOR''' i '''FROM''' '''LWB''' a + 1 '''TO''' '''UPB''' a '''DO''' ( a[i]>out | out:=a[i] ) '''OD'''; out) ====Array, Procedure, Dereference and coercion operations==== {|class="wikitable" |- ! style="background:#ccc;"|'''PRIO'''rity ! style="background:#ccc;"| Operation <sup>[[#The language of the unrevised report|r0]]&[[#Revisions|r1]]</sup> ! style="background:#ccc;"|+Algol68<sup>[[#The language of the unrevised report|r0]]</sup> ! style="background:#ccc;"|+Algol68<sup>G</sup> |- |ALIGN=CENTER| Effectively 12<br />(Primary) || dereferencing, deproceduring(~,~), subscripting[~], rowing[~,], slicing[~:~], size denotations '''LONG''' & '''SHORT''' || proceduring |ALIGN=CENTER|currying(~,,,), '''DIAG''', '''TRNSP''', '''ROW''', '''COL''' |- |ALIGN=CENTER| Effectively 11<br />(Secondary) || '''OF''' (selection), '''LOC''' & '''HEAP''' (generators) || β (selection) || '''NEW''' (generators) |} These are technically not operators, rather they are considered "[https://web.archive.org/web/20130101062456/http://jmvdveer.home.xs4all.nl/report.html#52 units associated with names]" <!-- '''DIAG''', '''TRNSP''', '''ROW''', '''COL''' as per S. G. van der Meulen, M. Veldhorst. TORRIX β A programming language for opera- tions on vectors and matrices over arbitrary fields and of variable size. Rijksuniver- siteit Utrecht [1977]. --> ====Monadic operators==== {|class="wikitable" |- ! style="background:#ccc;"|'''PRIO'''rity<br />(Tertiary) ! style="background:#ccc;"|Algol68 "Worthy characters{{ref|worthy}}"<sup>[[#The language of the unrevised report|r0]]&[[#Revisions|r1]]</sup> ! style="background:#ccc;"|+Algol68<sup>[[#The language of the unrevised report|r0]]&[[#Revisions|r1]]</sup> ! style="background:#ccc;"|+Algol68<sup>C,G</sup> ! style="background:#ccc;"|+Algol68<sup>[[#The language of the unrevised report|r0]]</sup> |- |ALIGN=CENTER| 10 || '''NOT''' ~, '''UP''', '''DOWN''', '''LWB''', '''UPB''', -, '''ABS''', '''ARG''', '''BIN''', '''ENTIER''', '''LENG''', '''LEVEL''', '''ODD''', '''REPR''', '''ROUND''', '''SHORTEN''' | Β¬, β, β, β, β | '''NORM''', '''TRACE''', '''T''', '''DET''', '''INV''' | '''LWS''', '''UPS''', β©, β§, '''BTB''', '''CTB''' |} <!-- '''NORM''', '''TRACE''', '''T''', '''DET''', '''INV''' as per S. G. van der Meulen, M. Veldhorst. TORRIX β A programming language for operations on vectors and matrices over arbitrary fields and of variable size. Rijksuniver-siteit Utrecht [1977]. --> ====Dyadic operators with associated priorities==== {|class="wikitable" |- ! style="background:#ccc;"|'''PRIO'''rity<br />(Tertiary) ! style="background:#ccc;"|Algol68 "Worthy characters"<sup>[[#The language of the unrevised report|r0]]&[[#Revisions|r1]]</sup> ! style="background:#ccc;"|+Algol68<sup>[[#The language of the unrevised report|r0]]&[[#Revisions|r1]]</sup> ! style="background:#ccc;"|+Algol68<sup>C,G</sup> ! style="background:#ccc;"|+Algol68<sup>[[#The language of the unrevised report|r0]]</sup> |- style="font-family:monospace" |ALIGN=CENTER|9 || +*, '''I''' || +Γ, β₯ || || ! |- style="font-family:monospace" |ALIGN=CENTER|8 || '''SHL''', '''SHR''', **, '''UP''', '''DOWN''', '''LWB''', '''UPB''' || β, β, β, β || || ΓΓ, ^, '''LWS''', '''UPS''', β©, β§ |- style="font-family:monospace" |ALIGN=CENTER|7 || *, /, %, '''OVER''', %*, '''MOD''', '''ELEM''' || Γ, Γ·, Γ·Γ, Γ·*, %Γ, β‘ || || Γ·: |- style="font-family:monospace" |ALIGN=CENTER|6 || -, + || || || |- style="font-family:monospace" |ALIGN=CENTER|5 || <, '''LT''', <=, '''LE''', >=, '''GE''', >, '''GT''' || β€, β₯ || || |- style="font-family:monospace" |ALIGN=CENTER|4 || '''EQ''' =, '''NE''' ~= /= || β , Β¬= || || |- style="font-family:monospace" |ALIGN=CENTER|3 || &, '''AND''' || β§ || || /\ |- style="font-family:monospace" |ALIGN=CENTER|2 || '''OR''' || β¨ || || \/ |- style="font-family:monospace" |ALIGN=CENTER|1 || '''MINUSAB''', '''PLUSAB''', '''TIMESAB''', '''DIVAB''', '''OVERAB''', '''MODAB''', '''PLUSTO''', -:=, +:=, *:=, /:=, %:=, %*:=, +=: || Γ:=, Γ·:=, Γ·Γ:=, Γ·*:=, %Γ:= || || '''MINUS''', '''PLUS''', '''DIV''', '''OVERB''', '''MODB''', Γ·::=, '''PRUS''' |} Specific details: * Tertiaries include names '''NIL''' and β. * '''LWS''': In Algol68<sup>[[#The language of the unrevised report|r0]]</sup> the operators '''LWS''' and β© ... both return '''TRUE''' if the ''lower state'' of the dimension of an array is fixed. * The '''UPS''' and β§ operators are similar on the ''upper state''. * The '''LWB''' and '''UPB''' operators are automatically available on '''UNION'''s of different orders (and '''MODE'''s) of arrays. eg. '''UPB''' of '''{{code|union([]int, [,]real, flex[,,,]char)}}''' ====Assignation and identity relations, etc.==== These are technically not operators, rather they are considered "[https://web.archive.org/web/20130101062456/http://jmvdveer.home.xs4all.nl/report.html#052 units associated with names]" {|class="wikitable" |- ! style="background:#ccc;"|'''PRIO'''rity<br />(Quaternaries) ! style="background:#ccc;"|Algol68 "Worthy characters"<sup>[[#The language of the unrevised report|r0]]&[[#Revisions|r1]]</sup> ! style="background:#ccc;"|+Algol68<sup>[[#The language of the unrevised report|r0]]&[[#Revisions|r1]]</sup> ! style="background:#ccc;"|+Algol68<sup>C,G,R</sup> ! style="background:#ccc;"|+Algol68<sup>[[#The language of the unrevised report|r0]]</sup> |- |ALIGN=CENTER| Effectively 0 || {{tt|1=:=, '''IS''' :=:, '''ISNT''' :/=: :~=:, '''AT''' @, ":", ";"}} || {{tt|1=:β : :Β¬=:}} | {{tt|1=:=:=<sup>C</sup>, =:=<sup>R</sup>}} || {{tt|1=..=, .=, '''CT''', ::, '''CTAB''', ::=, .., '''is not''', "..", ".,"}} |} Note: Quaternaries include names '''SKIP''' and ~. {{code|1=:=:}} (alternatively {{tt|1='''IS'''}}) tests if two pointers are equal; {{code|1=:/=:}} (alternatively {{tt|1='''ISNT'''}}) tests if they are unequal. =====Why {{code|1=:=:}} and {{code|1=:/=:}} are needed===== Consider trying to compare two pointer values, such as the following variables, declared as pointers-to-integer: : <code>'''REF''' '''INT''' ip, jp </code> Now consider how to decide whether these two are pointing to the same location, or whether one of them is pointing to '''NIL'''. The following expression : <code>ip = jp </code> will dereference both pointers down to values of type {{tt|1='''INT'''}}, and compare those, since the {{char|{{=}}}} operator is defined for {{tt|1='''INT'''}}, but not {{tt|1='''REF''' '''INT'''}}. It is ''not legal'' to define {{char|{{=}}}} for operands of type {{tt|1='''REF''' '''INT'''}} and {{tt|1='''INT'''}} at the same time, because then calls become ambiguous, due to the implicit coercions that can be applied: should the operands be left as {{tt|1='''REF''' '''INT'''}} and that version of the operator called? Or should they be dereferenced further to {{tt|1='''INT'''}} and that version used instead? Therefore the following expression can never be made legal: : <code>ip = '''NIL''' </code> Hence the need for separate constructs not subject to the normal coercion rules for operands to operators. But there is a gotcha. The following expressions: : <code>ip :=: jp </code> : <code>ip :=: '''NIL''' </code> while legal, will probably not do what might be expected. They will always return {{tt|1='''FALSE'''}}, because they are comparing the ''actual addresses of the variables ''<code>ip</code>'' and ''<code>jp</code>'', rather than what they point to''. To achieve the right effect, one would have to write : <code>ip :=: '''REF''' '''INT'''(jp) </code> : <code>ip :=: '''REF''' '''INT'''('''NIL''') </code> ====Special characters==== :[[Image:APL-keybd2.svg|600px|thumb|[[IBM 2741]] keyboard with APL symbols]] Most of Algol's "special" characters (β, β‘, β£, Γ, Γ·, β€, β₯, β , Β¬, β, β‘, β¨, β§, β, β, β, β, β, β©, β§, β₯, β¨, Β’, β and β‘) can be found on the [[IBM 2741]] keyboard with the [[APL (programming language)#Hardware|APL]] "golf-ball" print head inserted; these became available in the mid-1960s while ALGOL 68 was being drafted. These characters are also part of the [[Unicode]] standard and most of them are available in several popular [[font]]s.
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)