gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
270 stars 61 forks source link

FOR or FOREACH loop in a EXECUTE() command, itself in a main loop (!) works OK only on SECOND call #1849

Closed GillesDuvert closed 1 week ago

GillesDuvert commented 1 week ago

use:

pro biz1,calls
  counter=0
  for i=0,4 do z=execute(calls[i])
  print,counter
  for i=0,4 do z=execute(calls[i])
  print,counter
end
pro bizarre
  calls="for k=0,0 do counter++"
  what=replicate(calls,5)
  biz1,what
end

and get:

IDL> bizarre
% Compiled module: BIZARRE.
       5
      10
GDL> bizarre
% Compiled module: BIZARRE.
       1
       6

The problem arises only when in a loop in the execute command. calls="counter++" which is formally equivalent does not 'bug'

is This related to recent changes in prognode.cpp from the historical version (what says an old gdl?) Something vaguely similar: #1767 where first and 2nd use of a loop changes behaviour ?

GillesDuvert commented 1 week ago

closed by reverting the #1778 patch.