|Re: Question about RPL stack|
Message #2 Posted by Vieira, Luiz C. (Brazil) on 16 Oct 2001, 6:24 p.m.,
in response to message #1 by Chris Randle (Lincoln, UK)
Hello, Mr. Randle;
I do not have so much knowledge, but there is a single experience you would probably like to perform.
Be sure to disable all recovery features (UNDO, LASTARG, LASTCMD, LASTSTACK, all in the MODES menu, if I am not wrong). Then, type MEM [ENTER]. Write down this value.
Type in OR recall to the stack a somewhat big object (a program, a list, an array). If you recall it, MEM will return previous value LESS 2.5 bytes: the amouth of memory occupied by the LEVEL 1 pointer. The object IS NOT COPIED TO THE STACK, only the pointer to LEVEL 1 is created and is now pointing to the already existing object. If you typed in something, MEM will give you a new value, less than previous one.
Press [ENTER] a few times (4, 5, just a few). Type MEM again; 2.5 bytes for each copy , O.K.? Pointers for the levels the object is SUPPOSED to be copied in are just pointing to the same object.
How to change this? Edit one of them,change something and save the new, changed copied. In the stack, of course. say, edit the LEVEL 1 copy, remove or add something and press [ENTER]. MEM gives a lower available amouth of memory, now. Why? The edited copy is not a copy, is a new object which is pointed only by the LEVEL 1 pointer. Remove it by dropping it. MEM will lead to previous value, restoring the amouth of memory occupied by the edited copy as free, again.
One tricky thing: create a program with HALT as its first command; execute it ([EVAL]); when it is halted, purge it from memory; do you believe that trying to continue execution would crash? WRONG! A complete copy of the program is created and, even if removed, the copy itself resumes AND is then erased from memory, with an operation known as Garbage Collection.
Try it and, if needed, let us know.
Oh, yes; donīt forget to restore previous MODES settings for the recovery reatures after doing all of this!