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!
===2000s=== Microsoft added operator overloading to [[C Sharp (programming language)|C#]] in 2001 and to [[Visual Basic .NET]] in 2003. [[Scala (programming language)|Scala]] treats all operators as methods and thus allows operator overloading by proxy. In [[Raku (programming language)|Raku]], the definition of all operators is delegated to lexical functions, and so, using function definitions, operators can be overloaded or new operators added. For example, the function defined in the [[Rakudo]] source for incrementing a Date object with "+" is: <syntaxhighlight lang="perl6"> multi infix:<+>(Date:D $d, Int:D $x) { Date.new-from-daycount($d.daycount + $x) } </syntaxhighlight> Since "multi" was used, the function gets added to the list of [[multidispatch]] candidates, and "+" is only overloaded for the case where the type constraints in the function signature are met. While the capacity for overloading includes '''+''', '''*''', '''>=''', the [[Imaginary unit|postfix and term '''i''']], and so on, it also allows for overloading various brace operators: "'''['''x, y''']'''", "x'''['''y''']'''", "x'''{''y''}'''", and "x'''('''y''')'''". [[Kotlin (programming language)|Kotlin]] has supported operator overloading since its creation.
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)