Short-circuit Evaluation - Support in Common Programming Languages

Support in Common Programming Languages

Boolean operators in various 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 in, support, common, programming and/or languages:

    American families, however, without exception, experience a double message in our society, one that claims a commitment to families and stresses the importance of raising bright, stable, productive citizens, yet remains so bound by an ideal of “rugged individualism” that parents receive little support in their task from the public or private sectors.
    Bernice Weissbourd (20th century)

    American feminists have generally stressed the ways in which men and women should be equal and have therefore tried to put aside differences.... Social feminists [in Europe] ... believe that men and society at large should provide systematic support to women in recognition of their dual role as mothers and workers.
    Sylvia Ann Hewitt (20th century)

    We early arrive at the great discovery that there is one mind common to all individual men: that what is individual is less than what is universal ... that error, vice and disease have their seat in the superficial or individual nature.
    Ralph Waldo Emerson (1803–1882)

    If there is a price to pay for the privilege of spending the early years of child rearing in the driver’s 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)

    People in places many of us never heard of, whose names we can’t pronounce or even spell, are speaking up for themselves. They speak in languages we once classified as “exotic” but whose mastery is now essential for our diplomats and businessmen. But what they say is very much the same the world over. They want a decent standard of living. They want human dignity and a voice in their own futures. They want their children to grow up strong and healthy and free.
    Hubert H. Humphrey (1911–1978)