Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Femaref's answer is pretty good; I'd like to expand on it.</p> <p>Operators are (usually) hard-wired into the language: Stuff like <code>+</code>, <code>-</code>, <code>*</code> and <code>/</code> are usually directly translated by the compiler into machine language (if that's the underlying mechanism for that language system) without the need to explicitly call a method in a library. This is how it is/was in C, for instance. If those operators weren't defined in the language, you'd have to code <code>plus(2,2)</code> instead of <code>2 + 2</code>.</p> <p>Operators defined in the language come with the benefit of built-in priority. <code>*</code> and <code>/</code> usually have higher priority than <code>+</code> and <code>-</code>, so you can write <code>3 * 3 + 4 * 4</code> and get 25, not 52 or 84 that you'd get without such priorization or different priorities.</p> <p>The line becomes a little grey when operators are recognized by the compiler but still delegated to a library. Complex numbers in FORTRAN may be an example: Often the compiler will not bother to directly compile complex operations into machine code but will generate machine code to call a library.</p> <p>Most people think only of the arithmetic operators, like <code>+</code>, <code>-</code> and so forth. But you could also consider square brackets ( <code>[ ]</code> ) an operator for array indexing, for example.</p> <p>Some languages let you overload their operators, so you can substitute a call to a method for whatever the operator normally does.</p> <p>Most languages don't let you define your own operators that support the same mechanisms as the built-in ones. Scala is an exception here; you can define a <code>+++</code> operator if you like and have it hook up to a method you provide. Some people think operator overloading makes code harder to understand, so the jury is still out about whether this is a good idea.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload