Subroutine call performed as final action of a procedure
In computer science, a tail call is a subroutine call performed as the final action of a procedure.[1] If the target of a tail is the same subroutine, the subroutine is said to be tail recursive, which is a special case of direct recursion. Tail recursion (or tail-end recursion) is particularly useful, and is often easy to optimize in implementations.
Tail calls can be implemented without adding a new stack frame to the call stack. Most of the frame of the current procedure is no longer needed, and can be replaced by the frame of the tail call, modified as appropriate (similar to overlay for processes, but for function calls). The program can then jump to the called subroutine. Producing such code instead of a standard call sequence is called tail-call elimination or tail-call optimization. Tail-call elimination allows procedure calls in tail position to be implemented as efficiently as goto statements, thus allowing efficient structured programming. In the words of Guy L. Steele, "in general, procedure calls may be usefully thought of as GOTO statements which also pass parameters, and can be uniformly coded as [machine code] JUMP instructions."[2]
Not all programming languages require tail-call elimination. However, in functional programming languages, tail-call elimination is often guaranteed by the language standard, allowing tail recursion to use a similar amount of memory as an equivalent loop. The special case of tail-recursive calls, when a function calls itself, may be more amenable to call elimination than general tail calls. When the language semantics do not explicitly support general tail calls, a compiler can often still optimize sibling calls, or tail calls to functions which take and return the same types as the caller.[3]
^Steven Muchnick; Muchnick and Associates (15 August 1997). Advanced Compiler Design Implementation. Morgan Kaufmann. ISBN 978-1-55860-320-2.
^Cite error: The named reference aim-443 was invoked but never defined (see the help page).
In computer science, a tailcall is a subroutine call performed as the final action of a procedure. If the target of a tail is the same subroutine, the...
the tailcall optimizations discussed by Steele turned the procedure into a credible way of implementing iteration through single tail recursion (tail recursion...
implement tail-call optimization, allowing infinite recursion of a specific sort—tail recursion—to occur without stack overflow. This works because tail-recursion...
The tail is the section at the rear end of certain kinds of animals' bodies; in general, the term refers to a distinct, flexible appendage to the torso...
Scheme was the first dialect of lisp to use lexical scoping and to require tail-call optimization, features that encourage functional programming. In the 1980s...
Fairy Tail (stylized in all caps) is a Japanese manga series written and illustrated by Hiro Mashima. It was serialized in Kodansha's Weekly Shōnen Magazine...
A comet tail and coma are visible features of a comet when they are illuminated by the Sun and may become visible from Earth when a comet passes through...
interfere with the call stack information that can be recovered at runtime. For instance, inlining can cause missing stack frames, tailcall optimizations...
least since Algol 68. Functional programming languages tend to rely on tailcall optimization and higher-order functions instead of imperative looping...
used to implement tailcall elimination. One generalization of continuations are delimited continuations. Continuation operators like call/cc capture the...
using the call sign corresponding to the aircraft's registration number (also called N-number in the U.S., or tail number). In this case, the call sign is...
of tail-recursive call optimization, and thus efficient implementation of mutual tail recursion may be absent from languages that only optimize tail-recursive...
in tail position; mutually recursive subroutines must either use shared variables or pass state as parameters. Further, each mutually recursive call of...
In statistics and business, a long tail of some distributions of numbers is the portion of the distribution having many occurrences far from the "head"...
used, recur first into the smaller side of the partition, then use a tailcall to recur into the other, or update the parameters to no longer include...
requiring only constant memory overhead if tailcall optimization is available, or if eliminating the tail recursion with a loop: function select(list...
The empennage (/ˌɑːmpɪˈnɑːʒ/ or /ˈɛmpɪnɪdʒ/), also known as the tail or tail assembly, is a structure at the rear of an aircraft that provides stability...
implementation uses tailcall optimization (usually required for functional languages), objects may also be seen as escaping to called subroutines. If a...
An American Tail is a 1986 American animated musical adventure comedy-drama film directed by Don Bluth and written by Judy Freudberg and Tony Geiss from...