Augmented assignment (or compound assignment) is the name given to certain
assignment operators in certain programming languages (especially those derived from C). An augmented assignment is generally used to replace a statement where an operator takes a variable as one of its arguments and then assigns the result back to the same variable. A simple example is x += 1 which is expanded to x = x + 1. Similar constructions are often available for various binary operators.
In general, in languages offering this feature, most operators that can take a variable as one of their arguments and return a result of the same type have an augmented assignment equivalent that assigns the result back to the variable in place, including arithmetic operators, bitshift operators, and bitwise operators.
For example, the following statement or some variation of it can be found in many programs:
x = x + 1
This means "find the number stored in the variable , add 1 to it, and store the result of the addition in the variable ." As simple as this seems, it may have an inefficiency, in that the location of variable has to be looked up twice if the compiler does not recognize that two parts of the expression are identical: might be a reference to some array element or other complexity. In comparison, here is the augmented assignment version:
x += 1
With this version, there is no excuse for a compiler failing to generate code that looks up the location of variable just once, and modifies it in place, if of course the machine code supports such a sequence. For instance, if x is a simple variable, the machine code sequence might be something like
Load x
Add 1
Store x
and the same code would be generated for both forms. But if there is a special op code, it might be
MDM x,1
meaning "Modify Memory" by adding 1 to x, and an optimizing compiler would generate the same code for both forms. Some machine codes offer INC and DEC operations (to add or subtract one), others might allow constants other than one.
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.
"Hydrology for Engineers" is an introduction to the study of floods, droughts and a fair distribution of water. The course will introduce basic hydrologic concepts and methods: probability and statist
Swift est un langage de programmation objet compilé, multi-paradigmes, qui se veut simple, performant et sûr. Il est développé en open source. Le projet de développement de Swift est géré par Apple, qui en est également le principal contributeur ; mais de nombreux membres de la communauté Swift, ainsi que d'autres acteurs, tels que Google et IBM, participent également à son développement. Swift est officiellement supporté sur les systèmes d'exploitation Ubuntu, iOS, macOS, watchOS et tvOS.
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.
Introduit des outils de traitement de signaux statistiques pour les communications sans fil, mettant l'accent sur les applications pratiques et l'expérience pratique avec Python ou Matlab.
Students of programming languages in massive on-line open courses (MOOCs) solve programming assignments in order to internalize the concepts. Programming assignments also constitute the assessment procedure for such courses. Depending on their motivation a ...
Books on Demand GmbH, Norderstedt2016
Ada 83 did not provide enough control on the creation, assignment, and destruction of objects of user-defined types. This lack of control restricted type composition and prevented the full exercise of information hiding on Abstract Data Types. Ada 9X bring ...