February 02, 2012 Re: Segment violation (was Re: Why I could not cast string to int?) | ||||
---|---|---|---|---|
| ||||
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
|
February 02, 2012 Re: Segment violation (was Re: Why I could not cast string to int?) | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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
|
Copyright © 1999-2021 by the D Language Foundation