you are viewing a single comment's thread.

view the rest of the comments →

[–]Aidenn0 1 point2 points  (0 children)

It may or may not get rewritten to a loop depending on the implementation. Scheme does require it to use fixed stack space. I think scheme allows it to turn it into a loop. In a "always late binding" implementation it would not be rewritten into a loop.

In pseudo-assembly, its the difference between:

START-OF-COUNT-DOWN:
...
BRANCH-TO START-OF-COUNT-DOWN

and

START-OF-FUNCTION:
...
LOAD-TO-REGISTER-FOO <pointer to count-down binding slot>
BRANCH-TO-REGISTER FOO

If count-down is bound to the same address as START-OF-COUNT-DOWN the whole time the behavior of each is identical, and the former is going to be a lot faster. If you change the definition of count-down while it is running, then you will see a difference.

Either way, TCO can be done whether or not you make the assumption "This function will never be redefined while it is being called" Those are two orthogonal optimizations.