Re: "Nasty" bug

new topic     » goto parent     » topic index » view thread      » older message » newer message

I do not have a simple way to document the failure of oE for this "Nasty" bug.

This works. So the trap is set.

-- Version 1 
 
constant ball = 88 
sequence our_place = { 0, {0,0,0,0,0} }  
  
function you(integer thing)  
  integer score = rand(5) 
  our_place[2][score] = thing 
  printf(1, "__________________________ score %d \n", score ) 
    puts(1, "Inside  " ) ? our_place  
  return score  
end function  
 
for i=1 to 5 do 
    our_place[1] += you( ball )        -- OK 
    puts(1, "Outside ") ? our_place 
end for 
      
puts(1,"Done")  

Increasing the nesting of the sequence results in failure.

-- Version 2 
 
constant ball = 88 
  
sequence our_place = { {0}, {{0,0,0,0,0}} }   -- increased nesting  
  
function you(integer thing)  
  integer score = rand(5) 
  our_place[2][1][score] = thing 
      printf(1, "__________________________ score %d \n", score ) 
      puts(1, "Inside  " ) ? our_place  
  return score  
end function  
 
for i=1 to 5 do 
    our_place[1][1] += you( ball )        -- eui euc FAILING 
       puts(1, "Outside ") ? our_place 
end for 
      
puts(1,"Done")  

There is a fix

-- Version 3 
 
constant ball = 88 
  
sequence our_place = { {0}, {{0,0,0,0,0}} }   -- increased nesting  
  
function you(integer thing)  
  integer score = rand(5) 
  our_place[2][1][score] = thing 
      printf(1, "__________________________ score %d \n", score ) 
      puts(1, "Inside  " ) ? our_place  
  return score  
end function  
 
for i=1 to 5 do 
    atom tmp = you(ball)                --eui euc requires this fix 
    our_place[1][1] += tmp 
       puts(1, "Outside ") ? our_place 
end for 
      
puts(1,"Done")  
  • Phix works all of the time
  • oE does not work uniformly
    avoid functions that have side-effects!

_tom

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu