4 ms·
Memoization is one the most useful things I learned about in Common Lisp. Glad to see it in D. It allows the program to have recursive algorithms with the per
by Shorel 12y ago
Memoization is one the most useful things I learned about in Common Lisp. Glad to see it in D.
It allows the program to have recursive algorithms with the performance of optimized for loops.
- blt 12y agoMemoization is pretty easy to implement yourself without any special language support. It's cool to make it part of the standard library but it's not like some magic sauce. Especially given that D always uses hash tables. In the Fibonacci example given, a simple array would have much, much better performance.
- repsilat 12y ago> In the Fibonacci example given, a simple array would have much, much better performance. When I looked at the output of the hash function in Python for integers a few weeks ago it looked like the identity function was being used. You'll still have greater complexity than an array, but I'm not sure how much greater.
- Shorel 12y agoIt was dead easy in Common Lisp. That's the most impressive thing about it.
- jacobwcarlson 12y agoTail call optimization is necessary as well (or at least extremely beneficial). I don't know enough about D compilers to say whether or not they do this, but this discussion gives a strong "perhaps?": http://forum.dlang.org/thread/jk5jc0$25cd$1@digitalmars.com http://forum.dlang.org/thread/jk5jc0$25cd$1@digitalmars.com
- yoklov 12y agoNot really. Only if a hash table lookup is the first part of every iteration of the for loop. It does allow some recursive algorithms to reduce their algorithmic complexity significantly, however.