Tail Recursion and Tail Call Optimization: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
(Okay, I delayed this way more than I thought I would...)
Line 1:
== What is a tail call? ==
Formally, a call within a function is a tail call if the caller does not modify the state after the call and before returning.
 
Informally, a tail call is when a function calls another function, and returns immediately. In assembly, it's when a CALL and a RET instructions are found right next to each other. For example, in the following code:
 
Line 46 ⟶ 44:
 
As you can see, there is no operation between <code>CALL</code> and <code>RET</code> this time.
 
== Optimizing a tail call ==
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu