Support in Common Programming Languages
| Language | Eager operators | Short-circuit operators | Result type |
|---|---|---|---|
| ABAP | none | and, or |
Boolean1 |
| Ada, Eiffel | and, or |
and then, or else |
Boolean |
| ALGOL 68 | and, &, ∧ ; or, ∨ | andf, orf (both user defined) | Boolean |
| C2 | none | &&, ||, ? |
Numeric (&&,||), opnd-dependent (?) |
| C++3 | &, | |
&&, ||, ? |
Boolean (&&,||), opnd-dependent (?) |
| Go, OCaml, Haskell | none | &&, || |
Boolean |
| C#, Java,
MATLAB R |
&, | |
&&, || |
Boolean |
| ColdFusion | none | AND, OR, &&, || |
Boolean |
| Erlang | and, or |
andalso, orelse |
Boolean |
| Fortran | .and., .or. |
Boolean | |
| JavaScript | none | &&, || |
Last value |
| Lisp, Lua, Scheme | none | and, or |
Last value |
| Lasso | none | and, or, &&, || |
Last value |
| Modula-2 | none | AND, OR |
Boolean |
| Oberon | none | &, OR |
Boolean |
| Pascal | and, or4 |
and_then, or_else5 |
Boolean |
| Perl, Ruby | &, | |
&&, and, ||, or |
Last value |
| PHP | none | &&, and, ||, or |
Boolean |
| Python | none | and, or |
Last value |
| Smalltalk | &, | |
and:, or: |
Boolean |
| Standard ML | Unknown | andalso, orelse |
Boolean |
| Visual Basic .NET | And, Or |
AndAlso, OrElse |
Boolean |
| VB Script, VB Classic, VBA | And, Or |
Select Case |
Numeric |
1 ABAP does not actually have a distinct boolean type.
2 C, before C99, did not actually have a distinct boolean type; logical operators returned 0 (for false) or 1 (for true).
3 When overloaded, operators && and || are eager and can return any type.
4 ISO Pascal allows but does not require short-circuiting.
5 ISO-10206 Extended Pascal supports and_then and or_else.
Read more about this topic: Short-circuit Evaluation
Famous quotes containing the words support, common, programming and/or languages:
“I make this direct statement to the American people that there is far less chance of the United States getting into war, if we do all we can now to support the nations defending themselves against attack by the Axis than if we acquiesce in their defeat, submit tamely to an Axis victory, and wait our turn to be the object of attack in another war later on.”
—Franklin D. Roosevelt (18821945)
“I will not adopt that ungenerous and impolitic custom so common with novel writers, of degrading by their contemptuous censure the very performances, to the number of which they are themselves addingjoining with their greatest enemies in bestowing the harshest epithets on such works, and scarcely ever permitting them to be read by their own heroine, who, if she accidentally take up a novel, is sure to turn over its insipid leaves with disgust.”
—Jane Austen (17751817)
“If there is a price to pay for the privilege of spending the early years of child rearing in the drivers seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.”
—Melinda M. Marshall (20th century)
“Wealth is so much the greatest good that Fortune has to bestow that in the Latin and English languages it has usurped her name.”
—William Lamb Melbourne, 2nd Viscount (17791848)