On Friday, 27 July 2012 at 19:14:29 UTC, Stuart wrote:
On Friday, 27 July 2012 at 19:09:27 UTC, Paulo Pinto wrote:
On Friday, 27 July 2012 at 19:04:07 UTC, Stuart wrote:
Recursion isn't just a security risk - it's a performance hit
as well.
Only in languages without tail call optimizations.
Which is pretty much all of them.
Scheme does it, and probably HOPE too; but bugger-all you could
write a real program in, like .NET or C++. I mean, we're in
bloody FORTRAN territory here. What use is that for writing
Windows applications?
Does D have tail call optimisation?
Well, at least all of these:
- Scheme
- Haskell
- OCaml
- F#
- Erlang
- Clojure
- Some C and C++ compilers (gcc, Intel, MSVC in release mode)
- Most commercial Lisp compilers
Yes D compilers also do tail call optimizations in certain cases,
even if not specified in the language spec, picking up an old
thread
http://www.digitalmars.com/d/archives/digitalmars/D/learn/Tail_call_optimization_33772.html
--
Paulo