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
Operator overloading
(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!
===1960s=== The [[ALGOL 68]] specification allowed operator overloading.<ref>{{cite web |title=Report on the Algorithmic Language ALGOL 68, Section 10.2.2. |url=https://www.softwarepreservation.org/projects/ALGOL/report/Algol68_revised_report-AB-600dpi.pdf =Barry J. Mailloux |last3=Peck |first3=John E. L. |author-link3=John E. L. Peck |last4=Koster |first4= Cornelis H. A. |author-link4=Cornelis H.A. Koster |access-date=1 April 2007 |date=August 1968 |display-authors=etal}}</ref> Extract from the ALGOL 68 language specification (page 177) where the overloaded operators ¬, =, ≠, and '''abs''' are defined: 10.2.2. Operations on Boolean Operands a) '''op''' ∨ = ('''bool''' a, b) '''bool''':( a | '''true''' | b ); b) '''op''' ∧ = ('''bool''' a, b) '''bool''': ( a | b | '''false''' ); c) '''op''' ¬ = ('''bool''' a) '''bool''': ( a | '''false''' | '''true''' ); d) '''op''' = = ('''bool''' a, b) '''bool''':( a∧b ) ∨ ( ¬b∧¬a ); e) '''op''' ≠ = ('''bool''' a, b) '''bool''': ¬(a=b); f) '''op''' '''abs''' = ('''bool''' a)'''int''': ( a | 1 | 0 ); Note that no special declaration is needed to ''overload'' an operator, and the programmer is free to create new operators. For dyadic operators their priority compared to other operators can be set: '''prio''' '''max''' = 9; '''op''' '''max''' = ('''int''' a, b) '''int''': ( a>b | a | b ); '''op''' '''++''' = ( '''ref''' '''int''' a ) '''int''': ( a +:= 1 );
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)