[comp.sys.mac.hypercard] HC stack overflow

Arne.Venstad@elab-runit.sintef.no (11/09/90)

Hi,

I am working on a genealogy stack (still working in HC 1.2.x context, but will be switching
to 2.0 when possible). I have implemented a recursive graph (or really tree) coloring
algorithm in HyperTalk which works nicely in most cases.  The problem is that when the
heigth of the ancestor tree becomes to big (about 18-20 generations), the HC stack will
be exhausted. I know this is an inherent problem in HC (and other systems as well), but
I would be more happy if I could:

    1. Handle the stack overflow situation from my script (like on stackOverflowErr...),
    2. or calculate on beforehand the maximum number of recursions allowed for my message
       handler.
    3. Increase stack of HC.

I guess 3. is out of question, but it would have been fine to get some hints on how to
minimize the stack consumption for each execution of a message handler (like avoiding
to many repeats etc.).

I would also like to thank you people in Apples HyperCard team which are reading this
newsgroup and giving very valuable information.

Best regards,
Arne Venstad         	 Email: Arne.Venstad@elab-runit.sintef.no
ELAB-RUNIT
SINTEF
7034 Trondheim,
Norway.

matti@niksula.hut.fi (Matti Saavalainen) (11/18/90)

Talking about recursion, I would like to know how much recursion does
HC allow.  Just for fun, I did a script which sorted all the lines in
a single text field (HyperTalk certainly was *not* meant for this ;-),
using recursive quicksort.  When I tried to sort a text field where
the lines already were sorted, the sorting started, but after a while
I got a message "Too much recursion" (or something like that: I get my
messages in Finnish).
	What could cause this?  The script works fine if the field is
not sorted.  Is there a definitive limit for recursive calls?

--
?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?

                                         "A star fall,   
      Matti Saavalainen                   a phone call,
                                          it joins all,
   matti@niksula.hut.fi                   synchronicity"
                                                           ( The Police )

 ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ? 

tom@wcc.oz (Tom Evans) (11/23/90)

In article <MATTI.90Nov17211948@elektra.hut.fi>, matti@niksula.hut.fi (Matti Saavalainen) writes:
> 
> Talking about recursion, I would like to know how much recursion does
> HC allow.  Just for fun...
> Is there a definitive limit for recursive calls?

Just for fun:

HyperCard X1-1.2.5 in a 1 Mb partition under MultiFinder (size of
partition didn't make any difference)

	What			Loops till "too much recursion"
	-------------------------------------------------------
	Script calling itself as a function	17
	Button sending "mouseup"s to itself	30
	Script sending "on" messages to itself	53

Depends on what you're doing, but messages are slimmer than functions.

========================
Tom Evans  tom@wcc.oz.au  
Webster Computer Corp P/L, 1270 Ferntree Gully Rd Scoresby, Melbourne 3179
Victoria, Australia 61-3-764-1100  FAX ...764-1179