Short-circuit evaluation, minimal evaluation, or McCarthy evaluation (after John McCarthy) is the semantics of some Boolean operators in some programming languages in which the second argument is executed or evaluated only if the first argument does not suffice to determine the value of the expression: when the first argument of the AND function evaluates to false, the overall value must be false; and when the first argument of the OR function evaluates to true, the overall value must be true. In programming languages with lazy evaluation (Lisp, Perl, Haskell), the usual Boolean operators short-circuit. In others (Ada, Java, Delphi), both short-circuit and standard Boolean operators are available. For some Boolean operations, like exclusive or (XOR), it is not possible to short-circuit, because both operands are always required to determine the result. Short-circuit operators are, in effect, control structures rather than simple arithmetic operators, as they are not strict. In imperative language terms (notably C and C++), where side effects are important, short-circuit operators introduce a sequence point – they completely evaluate the first argument, including any side effects, before (optionally) processing the second argument. ALGOL 68 used proceduring to achieve user-defined short-circuit operators and procedures. The use of short-circuit operators has been criticized as problematic: The conditional connectives — "cand" and "cor" for short — are ... less innocent than they might seem at first sight. For instance, cor does not distribute over cand: compare (A cand B) cor C with (A cor C) cand (B cor C); in the case ¬A ∧ C , the second expression requires B to be defined, the first one does not. Because the conditional connectives thus complicate the formal reasoning about programs, they are better avoided. In any programming language that implements short-circuit evaluation, the expression x and y is equivalent to the conditional expression if x then y else x, and the expression x or y is equivalent to if x then x else y.

À propos de ce résultat
Cette page est générée automatiquement et peut contenir des informations qui ne sont pas correctes, complètes, à jour ou pertinentes par rapport à votre recherche. Il en va de même pour toutes les autres pages de ce site. Veillez à vérifier les informations auprès des sources officielles de l'EPFL.
Cours associés (33)
BIOENG-603: Sharing your research
Giving a research talk (say, at a conference, to your department or in your research group meeting) is a really important part of a scientist's career. This course is designed for anyone who will be g
EE-597: Engineering internship credited with master project (master in Electrical and Electronical engineering)
L'étudiant effectue un stage en entreprise dans un domaine d'activité où les compétences de l'ingénieur en électricité et électronique sont mises en valeur
Afficher plus
Concepts associés (16)
Opérateur (informatique)
En programmation informatique, un opérateur est une fonction spéciale dont l'identificateur s'écrit généralement avec des caractères non autorisés pour l'identificateur des fonctions ordinaires. Il s'agit souvent des équivalents aux opérateurs mathématiques pour un langage de programmation. Les opérateurs peuvent effectuer des opérations arithmétiques, booléennes ou agir sur des chaînes de caractères. Contrairement aux fonctions, les opérateurs fournissent souvent les opérations primitives du langage.
Operator associativity
In programming language theory, the associativity of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses. If an operand is both preceded and followed by operators (for example, ^ 3 ^), and those operators have equal precedence, then the operand may be used as input to two different operations (i.e. the two operations indicated by the two operators). The choice of which operations to apply the operand to, is determined by the associativity of the operators.
Operators in C and C++
This is a list of operators in the C and C++ programming languages. All the operators (except typeof) listed exist in C++; the column "Included in C", states whether an operator is also present in C. Note that C does not support operator overloading. When not overloaded, for the operators &&, ||, and , (the comma operator), there is a sequence point after the evaluation of the first operand. C++ also contains the type conversion operators const_cast, static_cast, dynamic_cast, and reinterpret_cast.
Afficher plus
MOOCs associés (6)
Find the right markets for your innovation - A tool for entrepreneurs and innovators for choosing which markets to play in.
Learn how to apply the Market Opportunity Navigator - a three-step tool for identifying, evaluating and strategizing market opportunities - to get the most value for your innovation.
Plasma Physics: Introduction
Learn the basics of plasma, one of the fundamental states of matter, and the different types of models used to describe it, including fluid and kinetic.
Plasma Physics: Introduction
Learn the basics of plasma, one of the fundamental states of matter, and the different types of models used to describe it, including fluid and kinetic.
Afficher plus

Graph Chatbot

Chattez avec Graph Search

Posez n’importe quelle question sur les cours, conférences, exercices, recherches, actualités, etc. de l’EPFL ou essayez les exemples de questions ci-dessous.

AVERTISSEMENT : Le chatbot Graph n'est pas programmé pour fournir des réponses explicites ou catégoriques à vos questions. Il transforme plutôt vos questions en demandes API qui sont distribuées aux différents services informatiques officiellement administrés par l'EPFL. Son but est uniquement de collecter et de recommander des références pertinentes à des contenus que vous pouvez explorer pour vous aider à répondre à vos questions.