<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Languages of the real and artificial - Latest Comments in One-Line JavaScript Memoization</title><link>http://osteele.disqus.com/</link><description></description><atom:link href="https://osteele.disqus.com/one_line_javascript_memoization/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sun, 10 Aug 2008 16:20:56 -0000</lastBuildDate><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881104</link><description>&lt;p&gt;Looks like it would work to me. Remember there are more than one way to skin a cat.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Cheap Airsoft Electric Guns</dc:creator><pubDate>Sun, 10 Aug 2008 16:20:56 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881103</link><description>&lt;p&gt;Why create a closure when you can just create a plain old function? It looks as simple as it is. No need to complicate things by calling the new function either.&lt;/p&gt;&lt;p&gt;Bezier.prototype.getLength = function() {&lt;br&gt;  var length = ... // expensive computation&lt;br&gt;  this.getLength = new Function ("return " + length);&lt;br&gt;  return length;&lt;br&gt;  }&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">playBunny</dc:creator><pubDate>Sun, 20 Jul 2008 06:10:34 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881102</link><description>&lt;p&gt;[...] One-Line JavaScript Memoization by Oliver Steele [...]&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Timed Memoization</dc:creator><pubDate>Sun, 06 Jan 2008 16:01:05 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881100</link><description>&lt;p&gt;Atany: thanks for the catch; 'tis done.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">osteele</dc:creator><pubDate>Wed, 15 Aug 2007 12:42:19 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881099</link><description>&lt;p&gt;[...] One line memoization in javascript [...]&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Links of the day « Geeks in th</dc:creator><pubDate>Mon, 21 May 2007 06:34:18 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881098</link><description>&lt;p&gt;[...] One-Line JavaScript Memoization at Oliver Steele [...]&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daily misery » Blog Archive » </dc:creator><pubDate>Thu, 17 May 2007 22:31:24 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881097</link><description>&lt;p&gt;Great article!&lt;/p&gt;&lt;p&gt;Could you please correct shortened memoizeConstantMethod to define local 'value' variable :)&lt;/p&gt;&lt;p&gt;The current version does not work correctly when called more then once for different methods.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">atany</dc:creator><pubDate>Thu, 17 May 2007 20:04:26 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881096</link><description>&lt;p&gt;Very cool technique, I wrote something like this in java some time ago, never thought about a javascript implementation. Great content you have on your blog! Thanks&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Bas Wenneker</dc:creator><pubDate>Thu, 17 May 2007 15:47:49 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881095</link><description>&lt;p&gt;Great stuff! I think you would enjoy this as well:&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.cs.cityu.edu.hk/~hwchun/31337/blog/2005/09/y-combinator-in-javascript.php" rel="nofollow noopener" target="_blank" title="http://www.cs.cityu.edu.hk/~hwchun/31337/blog/2005/09/y-combinator-in-javascript.php"&gt;http://www.cs.cityu.edu.hk/...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;This strikes me as something I might actually use in a number of practical cases though. Thanks for going into such detail, great explanations.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ryan Johnson</dc:creator><pubDate>Thu, 17 May 2007 15:10:10 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881093</link><description>&lt;p&gt;[...] For a “simple” language, Javascript is amazingly deep. Learning how to use a language with closures and runtime function generation just takes a shift in thinking from anything else I’ve done. The whole concept of memoization is just amazing. I think I’ve fallen off the strong-typing bandwagon. Oh if Bart could see me now… [...]&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">ben lowery » Thursday</dc:creator><pubDate>Fri, 27 Apr 2007 00:21:03 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881092</link><description>&lt;p&gt;Just as a sidenote: Trying to subscribe to any of the feeds, be it rss or atom, gives a 500.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steffen</dc:creator><pubDate>Mon, 22 Jan 2007 17:00:24 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881091</link><description>&lt;p&gt;[...] While reading Oliver Steele’s article on JavaScript Memoization this bit jumped out at me. [...]&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Williams » JavaScript Is</dc:creator><pubDate>Mon, 28 Aug 2006 02:42:46 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881090</link><description>&lt;p&gt;Inner functions should only need to capture their free references.  Are you just saying that most Javascript VM's are too simplistic, so they capture the entire scope chain?  Bleah.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">P T Withington</dc:creator><pubDate>Wed, 03 May 2006 11:23:35 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881089</link><description>&lt;p&gt;[...] One-Line JavaScript Memoization — JavaScript woodoo [...]&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">developers.org.ua » Blog Archi</dc:creator><pubDate>Fri, 21 Apr 2006 04:55:29 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881088</link><description>&lt;p&gt;Nice article oliver. I have to say that this restriction:&lt;br&gt;&amp;gt; The inner function captures the variables from the outer function.&lt;/p&gt;&lt;p&gt;makes me a little suspicious of the fancier solutions you present. It's true that the memoization is caught up in the domain logic, but I have needed to do this rarely enough that it hasn't really bothered me. I'm more wary of memory leaks or ineffeciencies in the underlying runtime when using closures than bugs caused by rewriting a little code to test for the presence of a stored value.&lt;/p&gt;&lt;p&gt;Also, here's another take on your memoization routine that uses arguments.callee instead of closures.&lt;/p&gt;&lt;p&gt;function assignMemoizable( object, func , name ){&lt;br&gt;    var f = function (){&lt;br&gt;        if stored value exists&lt;br&gt;            return from cache&lt;br&gt;        else&lt;br&gt;            return arguments.callee.originalFunction.apply( this , arguments );&lt;br&gt;    }&lt;br&gt;    f.originalFunction = func;&lt;br&gt;    object.prototype[ name ] = f;&lt;br&gt;}&lt;/p&gt;&lt;p&gt;That seems like it would work too, no?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Victor Laszlo</dc:creator><pubDate>Wed, 19 Apr 2006 03:40:21 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881087</link><description>&lt;p&gt;First -- I have been very much enjoying your blog. Very thought provoking and inspiring! As ever, your approach is simultaneously academic and practical.&lt;/p&gt;&lt;p&gt;This article taught me a few new words (nullary, memoize) which will come in handy, and a few more of JavaScript's subtleties.&lt;/p&gt;&lt;p&gt;So, memoization. I like it. But I'm just a simple engineer unconcerned with language theory, and more concerned with getting stuff to work good, and stuff. Keith Gaughan's solution -- appending .memoize() -- onto a function certainly seems the least intrusive and tidy. And, agreed, managing multiple files and dependencies on a server is annoying. One solution for that would be to introduce a build-step to the development, resulting in a single file. Yeah... Edit, make, test. It's not the craziest flow in the world, though it is one more darned thing.&lt;/p&gt;&lt;p&gt;Reassigning the function to "return length" is appealing but troubling. It's an opaque state, it's self-modifying code, oh, it troubles me. And even more so for the self-neutralizing "Thing.noFun = function(){};"!&lt;/p&gt;&lt;p&gt;While these strategies are interesting, I'm always concerned that my code may be maintained by cave men, or myself late on a Sunday. These dynamic features are, obviously, a lot of fun... but I must confess: I'll opt for the first naive "Thag not compute Bezier length twice if Thag already have Bezier length! Ha!" solution:  function bezierLength() { compute if needed, return }". Easy peasy.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">dvb</dc:creator><pubDate>Wed, 19 Apr 2006 03:01:14 -0000</pubDate></item><item><title>Re: One-Line JavaScript Memoization</title><link>http://blog.osteele.com/archives/2006/04/javascript-memoization#comment-4881086</link><description>&lt;p&gt;Nice technique and proposed idiom. (I also loved the Why combinator pun. :-)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Johan SundstrÃ¶m</dc:creator><pubDate>Tue, 18 Apr 2006 05:14:33 -0000</pubDate></item></channel></rss>