Re: recursion depth
Re: recursion depth
- Subject: Re: recursion depth
- From: has <email@hidden>
- Date: Sun, 9 Oct 2005 22:18:54 +0100
Matt Neuburg wrote:
>Okay, let's all test the depth of recursion, please.
How long is a piece of string?
Maximum recursion depth isn't a constant: it depends on the amount of memory allocated to the call stack and the size of each call frame stored on it. There could also be other factors at work. But without knowing all the details of the AS interpreter's design you're just shooting in the dark. Even coming up with a ballpark figure would be pretty meaningless, since you might get 16,000 recursions in one case while another tops out at under 200 (from my own experience, choice of host application is by far the biggest deciding factor). At best, you might arm-twist an AS engineer into giving you a list of all the variables at play, though probably all that'll really tell you is just how difficult it is to accurately predict this sort of thing.
FWIW, the only situation I can think of offhand where call stack overflows are a significant problem for ASers are in recursive sort routines such as quicksort. And you can avoid those by using non-recursive algorithms instead [1]; for example, AppleMods' List library provides a sortList() command that uses an iterative, stack-based version of the quicksort algorithm that can safely handle lists of any size.
HTH
has
[1] i.e. Anything you can do with recursion you can in principle also do with iteration, and vice-versa. Though a detailed discussion of such CS wonkishness probably - and understandably - falls too far outside the scope of your book.
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden