Editing Recursion

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 94: Line 94:
Despite languages slowly adding features from functional languages developed 40 years ago, tail call optimization is still unpopular. I'm guessing that the reason is because not many people see the use of recursion.
Despite languages slowly adding features from functional languages developed 40 years ago, tail call optimization is still unpopular. I'm guessing that the reason is because not many people see the use of recursion.


Here's an incomplete list of languages that support it automatically:
Here's an incomplete list of languages that support it:


* Lua (see [https://www.lua.org/pil/6.3.html Programming in Lua 6.3 - Proper Tail Calls])
* Clang C and C++ (see the [https://clang.llvm.org/docs/AttributeReference.html#musttail Clang musttail attribute])
* Tcl (see [https://www.tcl.tk/man/tcl/TclCmd/tailcall.html Tcl's tailcall manual page])
* Haskell
* Haskell
* Erlang (and Elixir)
* Erlang (and Elixir)
*Any Scheme implementation (Chez Scheme, Chibi Scheme, Chicken Scheme, TinyScheme)
*Any Scheme implementation (Chez Scheme, Chibi Scheme, Chicken Scheme, TinyScheme)
*Lua (see [https://www.lua.org/pil/6.3.html Programming in Lua 6.3 - Proper Tail Calls])
*Steel Bank Common Lisp (See [http://www.sbcl.org/manual/#Debug-Tail-Recursion SBCL Debug Tail Recursion])
*Steel Bank Common Lisp (See [http://www.sbcl.org/manual/#Debug-Tail-Recursion SBCL Debug Tail Recursion])
*Squirrel (See [http://squirrel-lang.org/squirreldoc/reference/language/threads.html Squirrel's Threads page])
*OCaml (See [https://ocaml.org/manual/attributes.html OCaml's tailcall attribute])
*Racket (See [https://docs.racket-lang.org/guide/Lists__Iteration__and_Recursion.html#%28part._tail-recursion%29 The Racket Guide 2.3.3 - Tail Recursion])
*Racket (See [https://docs.racket-lang.org/guide/Lists__Iteration__and_Recursion.html#%28part._tail-recursion%29 The Racket Guide 2.3.3 - Tail Recursion])
Here's an incomplete list of languages that require explicit support:
* Clang C and C++ (see the [https://clang.llvm.org/docs/AttributeReference.html#musttail Clang musttail attribute])
* Tcl (see [https://www.tcl.tk/man/tcl/TclCmd/tailcall.html Tcl's tailcall manual page])
*OCaml (See [https://ocaml.org/manual/attributes.html OCaml's tailcall attribute])
* Perl (See [https://perldoc.perl.org/functions/goto Perl's goto function], specifically the goto &NAME variant)
* Perl (See [https://perldoc.perl.org/functions/goto Perl's goto function], specifically the goto &NAME variant)
*Unix (See [https://jeapostrophe.github.io/2012-05-28-exec-vs--post.html exec and Tail-call Optimization])
*Unix (See [https://jeapostrophe.github.io/2012-05-28-exec-vs--post.html exec and Tail-call Optimization])
*Assembly (Instead of returning set up registers and jump)
*Assembly (Instead of returning set up registers and jump)
*Squirrel (See [http://squirrel-lang.org/squirreldoc/reference/language/threads.html Squirrel's Threads page])
*Ruby (See [https://nithinbekal.com/posts/ruby-tco/ Ruby's tailcall_optimization compile option])
*Ruby (See [https://nithinbekal.com/posts/ruby-tco/ Ruby's tailcall_optimization compile option])
*Zig (See [https://ziglang.org/documentation/master/#call Zig's always_tail call option])
*Zig (See [https://ziglang.org/documentation/master/#call Zig's always_tail call option])
Please note that all contributions to JookWiki are considered to be released under the Creative Commons Zero (Public Domain) (see JookWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)