I love using `labels`. For people used to Clojure, it allows a similar pattern as loop/recur. From my own testing, `labels` appears to do proper Tail Call Elimination for (at least) SBCL, ECL, CCL, Clasp, and LW8. As you mentioned with ABCL, it also doesn't seem to do TCE for `labels` either, unfortunately.
@@the-lisper True, ASM all just jumps. I have done some testing with the tail recursion in the Rust programming language too. Rust is very strict and clear about safety and reliability of everything. The docs clearly explain how tail recursion is also not guaranteed at all and should not be relied on. However, when I do very simple test with it, it currently does only stack overflow using a Debug build and not in the Release build, where it just goes infinite and 100 percent on a CPU thread without any crash. And this also fits into the more general zero cost philosophy or Rust, where it basically inlines and eliminates most functions and other abstractions. Which is why it runs so incredibly fast.
Thanks for this video. I Just started exploring Lisp a bit, out of fascination, and because it is an influence on some modern languages. Rust has inspiration out of it for example. I don't develop in pure functional languages (yet), but as far as I know is a general solution is to use recursive higher order functions like fold and reduce. At least from reduce I know that Lisp has that one as well. Obviously in fact this also shifts the problem. How are these functions implemented? Well probably with iteration. But I guess these functions are kind of made intrinsic in pure languages like Haskell. So that these details are more hidden to the eye.
Yes, it is common practise to use high level functions like map/reduce/filter/.... but what if you can't? Recursion and iteration are more generic concept, you can build the high level functions using them. These functions don't have to be intrisic.
I love using `labels`. For people used to Clojure, it allows a similar pattern as loop/recur. From my own testing, `labels` appears to do proper Tail Call Elimination for (at least) SBCL, ECL, CCL, Clasp, and LW8. As you mentioned with ABCL, it also doesn't seem to do TCE for `labels` either, unfortunately.
Thanks for sharing your experience!
Looks like kind of a functional version of the C style goto concept. It performs a jump, but it still behaves like a function. Fascinating.
@@jongeduard Behind the scene every loop/iteration (for, while, do ... while) is a goto! TCE is really changing recursion in iteration automatically!
@@the-lisper True, ASM all just jumps. I have done some testing with the tail recursion in the Rust programming language too. Rust is very strict and clear about safety and reliability of everything. The docs clearly explain how tail recursion is also not guaranteed at all and should not be relied on.
However, when I do very simple test with it, it currently does only stack overflow using a Debug build and not in the Release build, where it just goes infinite and 100 percent on a CPU thread without any crash.
And this also fits into the more general zero cost philosophy or Rust, where it basically inlines and eliminates most functions and other abstractions. Which is why it runs so incredibly fast.
Did the loop heap allocate? Rust's memory model prevents tail calls in certain cases.
Definitely do. This is Lisp. It should support anything that is useful to do.
Ja, the ANSI standard just doesn't mandate to optimize it. Even though it usually does (when possible)
Thanks for this video. I Just started exploring Lisp a bit, out of fascination, and because it is an influence on some modern languages. Rust has inspiration out of it for example.
I don't develop in pure functional languages (yet), but as far as I know is a general solution is to use recursive higher order functions like fold and reduce.
At least from reduce I know that Lisp has that one as well.
Obviously in fact this also shifts the problem. How are these functions implemented? Well probably with iteration. But I guess these functions are kind of made intrinsic in pure languages like Haskell. So that these details are more hidden to the eye.
Yes, it is common practise to use high level functions like map/reduce/filter/.... but what if you can't?
Recursion and iteration are more generic concept, you can build the high level functions using them. These functions don't have to be intrisic.