Three Cool Things about D
David Nadlinger via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Tue Dec 22 19:45:31 PST 2015
On Wednesday, 23 December 2015 at 01:07:57 UTC, Walter Bright
wrote:
> On 12/22/2015 10:29 AM, David Nadlinger wrote:
>> Not sure about how it arrives at the crazily unrolled loop,
>> but no recursion in
>> sight anymore.
>
> It's doing tail recursion optimization, which turns the
> recursion into a loop.
The recursive call is not quite a tail call by itself, which is
what Andrei pointed out using that example. But yes, that's what
happens.
> Then the loop is unrolled 8 times.
Sure thing. I was rather surprised to see that happen given that
I only compiled with -O1, though, as it seems to be quite an
aggressive optimization.
— David
More information about the Digitalmars-d-announce
mailing list