Hi,

block1: []
Each time around, block1 is pointed at a growing block, starting out
initially as [].
The block is modified to include "text1" each time round.
Remember, the thing that is actually modified is the []!!!
To see this, try this one-liner:
do a: does [loop 3 [blk: [] insert blk 'gold source a]]
You should notice that the thing that blk is pointing to is actually
growing in the source.

block2: to-block ""
This code gets evaluated each time, which means that the thing that block2
used
to point to (["text2"]) is forgotten in favour of the newly created [].

Regards,

Anton.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 18 October 2000 7:14 PM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] Block Creation
>
>
> Here's a block query...
>
> >> block1: []
> == []
>
> >> block2: to-block ""
> == []
>
> The above would appear to have created identical blocks, but as the
> following little script shows they're not the same...
>
> rebol []
> for test1 1 5 1 [
>     block1: []
>     insert block1 "text1"
> ]
> prin "block1: " print block1
> for test2 1 5 1 [
>     block2: to-block ""
>     insert block2 "text2"
> ]
> prin "block2: " print block2
>
> The output from this is...
>
> block1: text1 text1 text1 text1 text1
> block2: text2
>
> I'm assuming this is normal REBOL behaviour and not a bug, (and I
> know...
>
>     block1: [] clear block1
>
> would've given the same results as with to-block), but what's the
> point of the difference?
>
> Carl Read.

Reply via email to