Discussion:Programmation C/Opérateurs
Un livre de Wikibooks.
---
D'après Discuter:C_(langage), les opérateurs ++ et -- n'existent pas parce que les processeurs ont des instructions pour incrémenter/décrémenter, mais simplement parce que c'est plus court :
Contrairement à ce que suggère cet article, Dennis M. Ritchie (important développeur des langage B et C), affirme que les opérateurs de préincrémentation et de postincrémentation du langage ne sont pas reliées au PDP-11.
Dans son texte The Development of the C Language (http://cm.bell-labs.com/cm/cs/who/dmr/chist.html) il fait le commentaire suivant:
-
- Thompson went a step further by inventing the ++ and -- operators, which increment or decrement; their prefix or postfix position determines whether the alteration occurs before or after noting the value of the operand. They were not in the earliest versions of B, but appeared along the way. People often guess that they were created to use the auto-increment and auto-decrement address modes provided by the DEC PDP-11 on which C and Unix first became popular. This is historically impossible, since there was no PDP-11 when B was developed. The PDP-7, however, did have a few `auto-increment' memory cells, with the property that an indirect memory reference through them incremented the cell. This feature probably suggested such operators to Thompson; the generalization to make them both prefix and postfix was his own. Indeed, the auto-increment cells were not used directly in implementation of the operators, and a stronger motivation for the innovation was probably his observation that the translation of ++x was smaller than that of x=x+1.
De plus, les choses du type "j = i++ + ++i;" sont plus à comportement indéfini que non portables.
Je me suis contenté de corriger les fautes d'orthographe. À noter beaucoup de répétitions des mots "subtil" et "sybillin". ;)
---
- Bonnes remarques, corrigez directement le wiki, c'est plus simple ! Thierry Pierron 23 jan 2005 à 02:36 (UTC)