Hi Charles,
> First off, my thanks to everyone demonstrating The Way Things Work. I don't > get to work in REBOL all that much anymore, so what knowledge I had of it has > dwindled, and I find myself looking at older code of my own and thinking, "Why > did I do that? It works, but *how* does it work?" > > > char-sequence: next [a b c d e] > > > > This line has three values - a set-word!, a word! and a block!. When this > > line is evaluated, again a block! series of values will be created, this > > time of five words (a, b, c, d, e). The block! will be at its head (head? > > returns true). Then NEXT is evaluated and it takes the block as input. NEXT > > returns a different block! value - that is the new block! has a different > > index to the original but retains a reference to the same sequence of > > elements. Finally in the evaluation, char-sequence is set to refer to this > > new block! and if you perform INDEX? on char-sequence afterwards, you will > > get the value 2 returned. If you performed FIRST HEAD char-sequence you > > would get the value 'a returned. > Whoah. That.... damn. That's just screwed up. So if I POKE a new value > into the original sequence, the char-seq gets changed as well. Wow. Time to > make prodigious use of COPY, it looks like. *whistles* Not screwed up at all :^) C'mon Charles, you were the one that mentioned pointers! C represents strings with a pointer to char, and if you want to make a duplicate of a string in C you have to use strcpy or whatever it is called. And you could have two pointers to the same string in C. So yes, there is only one sequence of elements, and yes COPY has a very good purpose. However, this whole pointer description is avoided in REBOL docs because it is not really required - it is only useful for old-language programmers ;^) REBOL uses word! as a symbol. You can set a word to a value but that does not mean that the word has the datatype of the value - only the value has that, the word is simply a reference to the value. And as I mentioned before more than one word could refer to the same thing, and the same word over time can refer to values of completely different datatypes. > > > So now this next expression of six values > > a: next b: next c: next sequence: [a b c] > <snip> > > Now if you try printing A you will get an error message. This is because A's > > index is past the tail of the series. But A can still be used try printing > > HEAD A. So in this last example I have made four seperate references to the > > same underlying data series and each of these is referred to by a different > > word (A, B, C and Sequence). > AAAAAIIIIIEEEE!!!!! *gun shot* > > > > Thanks for your help, Brett. > > > > My pleasure. I hope the descriptions above are useful and not uselessly > > wordy! > Heh. No, not too wordy. However, I am now frightened of REBOL ;) CarlS is > certainly a madman ;) :^)) Actually I feel safer using REBOL than all the other languages I programmed with over nearly two decades. The expectations and assumptions we bring to a new situation colour it in a certain way but it may not be the "reality" or the way we'll see the situation in time. My little bit of philosophy for the day. :^) Regards, Brett. -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.