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!
====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>
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)