MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Recursion limit: a good idea to ignore?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82301] Re: Recursion limit: a good idea to ignore?
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Wed, 17 Oct 2007 04:01:40 -0400 (EDT)
  • References: <feutsm$st$1@smc.vnet.net> <ff1oi3$88r$1@smc.vnet.net>

Jon Harrop wrote:
> In[1]:= f[0] := 0
> 
> In[2]:= f[n_] := 1+f[n-1]

> In[4]:= $RecursionLimit=Infinity
> 
> Out[4]= Infinity

> In[7]:= f[100000]
> Segmentation fault
> 
> So recursing too deep (applying your function to a large problem) can cause
> the whole Mathematica kernel to die when it overruns the system stack.

[...]

> $ ocamlnat
>         Objective Caml version 3.10.0 - native toplevel
> 
> # let rec f = function
>     | 0 -> 0
>     | n -> 1 + f(n - 1);;
> val f : int -> int = <fun>

> # f 1000000;;
> Stack overflow during evaluation (looping recursion?).
> #

> Note that OCaml [...] failed with a nice
> catchable exception.

I wish Mathematica did that too instead of crashing and causing one to 
lose all data stored in the Kernel.

-- 
Szabolcs


  • Prev by Date: Re: Releasing several Holds simultaneously
  • Next by Date: Re: InverseFourierTransform strange behaviour
  • Previous by thread: Re: Recursion limit: a good idea to ignore?
  • Next by thread: Re: Recursion limit: a good idea to ignore?