www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Re: Segment violation (was Re: Why I could not cast string to int?)

reply bearophile <bearophileHUGS lycos.com> writes:
Timon Gehr:

 This is not a tail-recursive function. And neither is recFactorial, my 
 bad. Anyway, my point was that the compiler should not generate code 
 that blows up on a (in principle) perfectly sane implementation.

Is it possible to create a function attribute like tail_recursive that produces a compile error if you apply it to a function that's not tail-recursive? Bye, bearophile
Feb 02 2012
parent "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Thursday, February 02, 2012 18:17:36 bearophile wrote:
 Timon Gehr:
 This is not a tail-recursive function. And neither is recFactorial, my
 bad. Anyway, my point was that the compiler should not generate code
 that blows up on a (in principle) perfectly sane implementation.

Is it possible to create a function attribute like tail_recursive that produces a compile error if you apply it to a function that's not tail-recursive?

I suspect that Walter would feel the same way about that that he feels about something like marking functions as inline - i.e. that sort of thing should be left up to the compiler to optimize or not as it sees appropriate. - Jonathan M Davis
Feb 02 2012