Re: Recursion question?

new topic     » goto parent     » topic index » view thread      » older message » newer message

At 08:26 AM 14/12/00 -0500, you wrote:
>On Thu, 14 Dec 2000 19:38:01 +1100, Graeme <graemeburke at CROSSWINDS.NET>
>wrote:
>
>>>
>>>When a recusive function is used in Euphoria, are all the internal
>>>variables (including anything passed into the function) put in a stack of
>>>some kind? Ferinstance:
>>
>>Yes.
>>Private variables are the property of each instance of
>>a function and stay in memory until the termination of
>>that instance. (cool huh?;)
>>
>
>G'day all
>Thanks, Graeme. Does that mean that a recursive function with *lots* of big
>sequences and recursed *lots* of times will eat up heaps of memory? My poor
>old P166 16Mb beast goes from slow to s...l...o...w after looping around
>one of these things for a while. I guess running out of RAM will do that :)
>
>Regards
>Tony
>
>



Not Nesesarily.

Euphoria is pretty tricky about how it copies sequences.
Initially, it only copies a pointer to the sequence.
The sequence will only be actually copied when one of the
two(or more) variables that is assigned to it is modified.
So basically if they're read only, you can make any number
of copies of a sequence for virtually no memory overhead,
you only 'pay' for the copy when you modify it.

What are you doing? Will a local sequence of some kind
that all instances can work on do the job?

Graeme.

----------------------------------------------------

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu