[ALLY] Re(2): Trouble with timers???
From: arolls:bigpond:au at: 25-Apr-2001 17:17
> Thank you, that was very helpful. But why then does this happen?
>
> a: [42]
> a: []
> empty? a
> == true
1)
First, you are setting 'a to a block with 42 in it.
Then, you are setting 'a to an empty block.
The old block (with 42 in it), is now not being
referenced by anything, so it will be garbage
collected.
2)
When you run a program, it gets loaded into memory,
then run.
The part of your program that assigns the block looks
like this in memory:-
blk: []
After adding some values to blk, the part of your
program that assigns the block now looks like this
in memory:-
blk: [1:01 3:41] ; for example, a couple of times were added.
So it's not making a new block anymore!
blk gets set to point to what it is pointing to already.
It is as if the empty block [] that you wrote in is
literally being added to in the source.
3)
When you modify a copy of a block, the original block
never gets changed, so you can continue to make copies
of it, safe in the knowledge that it is indeed empty.
Anton.