Segment violation (was Re: Why I could not cast string to int?)
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Feb 2 14:47:22 PST 2012
On Thu, Feb 02, 2012 at 10:55:06PM +0100, Timon Gehr wrote:
> On 02/02/2012 08:04 PM, xancorreu wrote:
[...]
> >For the other hand, how can increase the stack in linux?
[...]
>
> I don't know, but it is best to just rewrite the code so that it does
> not use recursion.
>
> (This kind of problem is exactly the reason why any language standard
> should mandate tail call optimization.)
Doesn't help badly-chosen implementations like:
int fib(int n) {
if (n <= 2) return 1;
else return fib(n-2) + fib(n+1);
}
There's not much the compiler can do to offset programmers choosing the
wrong algorithm for the job. It can't replace educating programmers to
not implement things a certain way unless they have to.
T
--
Philosophy: how to make a career out of daydreaming.
More information about the Digitalmars-d-learn
mailing list