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

[REBOL] Re: bug?

From: koopmans:itr:ing:nl at: 20-Sep-2001 13:48

OK, I'll try.... You create a value and a word in the function context. You append "1" to the value. The function context lives as long as the function is defined, not as long as the invocation lasts. So the next time you call dummy, you append "1" to the value. If you understand pointers in C, think of return-value as a pointer and 1 of the value the pointer points to. You change the latter every invocation for the (changed) value "1". If you change "1" to copy "1" it will work as you expect, because you allocate new memory (a new value). Redeclaring return-value does not create a new pointer to a new value, as that pointer already existed in this context. The trick is that a string value is unique in the value domain, thus if you use a value, and change it, you actually redefine the value. Changing the value of a value in a context or so ;-) Although the above explanation is not 100% correct, the C analogy helps me most of the time. (and Rebil is written in ANSI C ). HTH, Maarten