Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Suspected bug

From: joel:neely:fedex at: 11-Aug-2000 11:39

The code at the bottom of this email displays either a bug in REBOL 2.3.0.4.2 or a bug in my head. The sample was quickly cut down from a larger program under development to try to demonstrate the key issue, so it's a bit untidy. The code was supposed to perform a sort of 2-d traversal of the alphabet. After a letter is picked for the row, pick a letter for the column and, in the original program, do something which involves comparing the row and column letters. In the sample output immediately below, it is obvious that one method of getting the row letter (using a shared local variable) fails miserably, getting stuck on the dummy value to which that variable was initialized, and never sees any subsequent changes to the variable. The second method of getting the row letter (passing it as an argument) works, demonstrating that the letter is actually changing. A : ~ B : ~ C : ~ D : ~ E : ~ F : ~ G : ~ A : A B : A C : A D : A E : A F : A G : A A : ~ B : ~ C : ~ D : ~ E : ~ F : ~ G : ~ A : B B : B C : B D : B E : B F : B G : B A : ~ B : ~ C : ~ D : ~ E : ~ F : ~ G : ~ A : C B : C C : C D : C E : C F : C G : C A : ~ B : ~ C : ~ D : ~ E : ~ F : ~ G : ~ A : D B : D C : D D : D E : D F : D G : D A : ~ B : ~ C : ~ D : ~ E : ~ F : ~ G : ~ A : E B : E C : E D : E E : E F : E G : E A : ~ B : ~ C : ~ D : ~ E : ~ F : ~ G : ~ A : F B : F C : F D : F E : F F : F G : F A : ~ B : ~ C : ~ D : ~ E : ~ F : ~ G : ~ A : G B : G C : G D : G E : G F : G G : G So... Why does 'doindx1 fail, while 'doindx2 succeeds? Shouldn't changes to the local variable 'initial in 'run be visible to both of them (albeit by different mechanisms)? -jn- REBOL [] bug: make object! [ run: function [ ][ initial alphabet letter doindx ][ initial: #"~" letter: #"~" doindx1: func [] [ foreach letter alphabet [ prin [letter ":" initial " "] ] print " " ] doindx2: func [initial] [ foreach letter alphabet [ prin [letter ":" initial " "] ] print " " ] alphabet: "ABCDEFG" foreach initial alphabet [ doindx1 doindx2 initial print " " ] ] ]