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

[REBOL] blocks in and out function !

From: olivier:flauzac:univ-reims at: 8-Jan-2002 20:07

Hi ! I'm try to developpe some rebol code, and I have a little problem : When I do the following code in the rebol console, everything is OK the last append instruction append 4 to the empty block following 1 ----------------------------------------------- gr: [] == []
>> append gr 1
== [1]
>> append/only gr []
== [1 []]
>> append gr 2
== [1 [] 2]
>> append/only gr []
== [1 [] 2 []]
>> append select gr 1 4
== [4]
>> :gr
== [1 [4] 2 []] ------------------------------------------------- now if I write the following functions I obtain a totally different result : 4 is append to all empty blocks !! ---------------------------------------------------
>> addNode: make function! [g n][
[ append g n [ append/only g [] [ ]
>> addLink: make function![g n v][
[ append select g n v [ ]
>> gr: []
== []
>> addNode gr 1
== [1 []]
>> addNode gr 2
== [1 [] 2 []]
>> addLink gr 1 4
== [4]
>> :gr
== [1 [4] 2 [4]] ----------------------------------------- I solved that problem by replacing the line "append/only g []" by append/only g make block! [] . With that modification It works ! Could anyone give me an explaination ? Why the second code do not behave like the first one ? Best Olivier Flauzac