<?xml version='1.0' encoding='iso-8859-1'?><?xml-stylesheet type='text/xsl' href='http://w3future.com/w3f/w3f.xsl' ?>
<html xmlns="http://www.w3.org/2002/06/xhtml2" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xf="http://www.w3.org/2002/xforms/cr" xml:lang="en" xml:base="http://w3future.com/weblog/2003/02/16.xml">
<head>
<title>Sunday, February 16, 2003 - Sjoerd Visscher's weblog</title>
<link rel="meta" type="application/rdf+xml" title="FOAF" href="http://w3future.com/people/sjoerd_visscher/foaf.rdf" />
</head>
<body>
<section id="content">
	<h>Sjoerd Visscher's weblog</h>
	<p>Pondering those web technologies that may change the future of the world wide web.</p>
	<section id="note">
		<h>Last Update</h>
		<p>10/16/2005; 1:25:49 AM</p>
		<p id="alternates" class="buttons">
			<l href="http://w3future.com/weblog/2003/02/16.xml?notransform" rel="alternate" type="application/xml" title="See this web page with XHTML 2.0 technology."><span>Try</span> XHTML 2.0</l>
			<l href="view-source:http://w3future.com/weblog/2003/02/16.xml?notransform" title="View the XHTML 2.0 source of this page."><span>Src</span> XHTML 2.0</l>
			<l href="http://w3future.com/tools/xr.pl?xr=http://w3future.com/xr/w3f.xml&amp;xml=http://w3future.com/weblog/2003/02/16.xml%3Fnotransform" rel="meta" type="application/rdf+xml" title="RDF metadata"><span>RDF</span> Metadata</l>
		</p>
		<xi:include href="http://w3future.com/w3f/buttons.xml" />
	</section><section>
  <h><a rel='prev' href='http://w3future.com/weblog/2003/02/13.xml#a165' title='Thursday, February 13, 2003'>&lt;&#160;</a><a href="http://w3future.com/weblog/2003/02/16.xml">Sunday, February 16, 2003</a><a rel='next' href='http://w3future.com/weblog/2003/02/27.txt#a167' title='Thursday, February 27, 2003'>&#160;&gt;</a></h>
<a name="a166"></a>
<section id="a166">
<h id='paulGrahamsAccumulatorGeneratorInLoell'><a href="http://w3future.com/weblog/2003/02/16.xml#a166" class="weblogItemTitle">Paul Graham's Accumulator Generator in Loell</a></h>
<p>When I read about <a href="http://www.paulgraham.com/accgen.html">Paul Graham's Accumulator Generator</a> on <a href="http://lambda.weblogs.com/discuss/msgReader$5779">Lambda the Ultimate</a>, I tried it in <a href="http://w3future.com/html/loell/">Loell</a>. As it turned out the solution was shorter than any of the solutions on Paul's page, without being complex. So I wrote an e-mail to Paul Graham:</p>
<blockquote><p>I don't know if you accept personal pet programming languages for your Accumulator Generator. Anyway I hope you are interested in Loell, because the solution seems to be the shortest one yet:</p>
<pre>foo={\n;{n+=that}}</pre>
<p>To test this go to http://w3future.com/html/loell/ and run this piece of code:</p>
<pre>foo={\n;{n+=that}}
 
x = $ foo 1
$ x 5
$ foo 3
$ x 2.3</pre>
<p>Actually, because Loell is (meant to be) object-oriented, the functions are methods of the current scope object ($). Method calls always have the format: object methodName argument. That's why the function calls look like the way they do.</p>
<p>Originally the default argument name was "_" like in Arc. I changed it to "that" to match "this" as the name for the left-hand side of a method call. If I hadn't, the solution would have been almost the shortest imaginable: <code>foo={\n;{n+=_}}</code></p>
<p>Note that there are no tricks involved, it's just that the syntax for closures is so short: {}.</p></blockquote>
</section>
</section>
<xi:include href='http://w3future.com/tools/rdf.php?about=http://w3future.com/weblog/2003/02/16.xml' /></section>
<section id="navigation"><xi:include href="http://w3future.com/w3f/sections.xml" /></section>
<section id="sidebar"><xi:include href="http://w3future.com/weblog/sidebars/weblog.opml" /></section>
</body>
</html>

