Thanks for the quick reply, and the great info I get on this list. Maybe
more to the point would be a function like so:

(de foo (Lst)
  # some kind of escape condition usually here
  (foo (modified-copy Lst)) )

Where modified-copy is a function that returns a *new* list.

After, say, the tenth time foo is called, are there now ten lists in memory?

Rationale: In some cases it feels safer and more natural to implement
the algorithm as a recursive algorithm where you are always passing
around modified copies of the data.

Or do we have to use loops and set a variable each iteration?

On 02/25/2017 11:06 PM, Alexander Burger wrote:
> On Sun, Feb 26, 2017 at 08:31:37AM +0100, Alexander Burger wrote:
>>       (let A (bar (copy Lst))
>>          (off Lst)
>>          (doSomethingWithTheCopy)
>>          ...
>>
>> With (off Lst) *one* refernce to the list is cleared, but the list will be
>> garbage collected only when the *last* reference is gone, which is not under
>> control of 'foo'.
> 
> Of course, if you *know* that 'Lst' is not owned by anybody else, i.e. it was
> freshly created by reading or list manipulations etc., you don't need to copy 
> it
> at all in the first place. 'copy' is used rather seldom, in cases where you 
> want
> to do destructive operations on list that might be owned by someone else.
> 
> ♪♫ Alex
> 

-- 
https://qlfiles.net
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to