bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

attribution of ++ to the wrong variable in "a ++b"


From: Pascal Maugis
Subject: attribution of ++ to the wrong variable in "a ++b"
Date: Tue, 13 Sep 2022 12:42:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

Hi, as promised here is the strange, unexpected behavior of ++ that looks like an error to me, because in "a ++b", a is incremented instead of b. "a b++" and "a++ b" produce the correct results however :

   touch a.awk
   gawk -D -f ./a.awk
   eval "a=1 ; b=2"
   eval "print a ++b"   ; output = 12 : (variables will be incremented
   after the operation, ok with me as documented)
   eval "print a b"     ; output = 22 : a has been incremented instead of b
   eval "print a++b"    ; output = 22 :
   eval "print a b"     ; output = 32 : a has been incremented

The operation seems to be interpreted as "a++b", the space been uninterpreted as a separator

Thanks for your insight,

Cheers,

Pascal.

--
------------------------------------------------------------------------

*Pascal MAUGIS*
Modélisation hydrologique et changement climatique, PhD

LSCE

Laboratoire des Sciences du Climat et de l'Environnement <http://www.lsce.ipsl.fr/>

Unité Mixte de Recherche CEA-CNRS-UVSQ (UMR 8212), IPSL, Paris-Saclay
Equipe MOSAIC : MOdelisation des SurfAces et Interfaces Continentales
Bât. 714, pièce 2115
C.E. Saclay, Orme des Merisiers, 91191 Gif-sur-Yvette Cedex, FRANCE

e-mail : pascal.maugis@lsce.ipsl.fr
Page perso : FR <http://www.lsce.ipsl.fr/Pisp/pascal.maugis/> - EN <http://www.lsce.ipsl.fr/en/Phocea/Pisp/index.php?nom=pascal.maugis>
Tel./Fax : +33 1 69 08 75 24 / +33 1 69 08 77 16

------------------------------------------------------------------------


reply via email to

[Prev in Thread] Current Thread [Next in Thread]