<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code by Martin</title>
	<atom:link href="http://martin.elwin.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://martin.elwin.com/blog</link>
	<description>Words about stuff...</description>
	<lastBuildDate>Mon, 26 Jan 2009 16:58:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Hitchhiker&#8217;s Guide to an Ioke Dev Env From Source (part 5: Ioke and the REPL)</title>
		<link>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-5/</link>
		<comments>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-5/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 06:45:45 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[ioke]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=148</guid>
		<description><![CDATA[This is the fifth part in a series of posts for non-experts about setting up an Ioke development environment on Linux. Please see the previous posts to start at the beginning:

Part 1: Git
Part 2: Emacs
Part 3: emacs-starter-kit
Part 4: Java and Ant

This time we will finally get the Ioke source code, build it, and test the [...]]]></description>
			<content:encoded><![CDATA[<p>This is the fifth part in a series of posts for non-experts about setting up an Ioke development environment on Linux. Please see the previous posts to start at the beginning:</p>
<ul>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-1/">Part 1: Git</a></li>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-2/">Part 2: Emacs</a></li>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-3/">Part 3: emacs-starter-kit</a></li>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-4/">Part 4: Java and Ant</a></li>
</ul>
<p>This time we will finally get the Ioke source code, build it, and test the Ioke <a href="http://en.wikipedia.org/wiki/REPL">REPL</a>!</p>
<h3>Ioke</h3>
<p>Ioke uses <a href="http://git-scm.com">Git</a> as the source code versioning tool, with a <a href="http://github.com/olabini/ioke">public repository</a> set up on <a href="http://github.com/">GitHub</a> (soon I&#8217;ll be linking like Jeff Atwood).</p>
<p>So &#8211; let&#8217;s get Ioke using Git by cloning Ola&#8217;s repository:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/bin$ cd ~/work
~/work$ git clone git://github.com/olabini/ioke
Initialized empty Git repository in /home/melwin/work/ioke/.git/
remote: Counting objects: 9221, done.
remote: Compressing objects: 100% (2941/2941), done.
remote: Total 9221 (delta 5782), reused 8656 (delta 5351)
Receiving objects: 100% (9221/9221), 45.95 MiB | 399 KiB/s, done.
Resolving deltas: 100% (5782/5782), done.</pre></div></div>

<p>Great &#8211; let&#8217;s quickly move on to the build step:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work$ cd ioke
~/work/ioke$ ant
...
     [java] 2606 examples, 0 failures
jar:
      [jar] Building jar: /home/melwin/work/ioke/lib/ioke.jar
&nbsp;
BUILD SUCCESSFUL
Total time: 22 seconds</pre></div></div>

<p>Running just <code>ant</code> will execute the default target in the <code>build.xml</code> file. This target will make sure Ioke is compiled and the test suite is run.</p>
<p>At the end is a summary of the test results &#8211; if these are not all successful you might have a problem with the environment or you might have checked out a broken build from the repository.</p>
<h3>The Ioke REPL</h3>
<p>Now all is installed and Ioke is compiled, so let&#8217;s fire up the REPL. This is done by just running the main Ioke binary:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work/ioke/$ bin/ioke
iik&gt;</pre></div></div>

<p>When doing this we get the <code>iik></code> REPL prompt. From here we can execute most Ioke code. Let&#8217;s try to print a string:</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;">iik<span style="color: #66cc66;">&gt;</span> <span style="color: #ff0000;">&quot;Hello World!&quot;</span> <span style="color: #000000; font-weight: bold;">println</span>
Hello World<span style="color: #66cc66;">!</span>
+<span style="color: #66cc66;">&gt;</span> <span style="color: #b1b100;">nil</span>
&nbsp;
iik<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>Here we create a Text (Ioke&#8217;s string type) literal and send it the message <code>println</code>, which will cause the text to be printed to the console. The return type of <code>println</code> is <code>nil</code> (similar to null), which is printed by the REPL itself. After that we get the prompt back and can execute another line.</p>
<p>Let&#8217;s try a little more complex example &#8211; the factorial:</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;">iik<span style="color: #66cc66;">&gt;</span> fact = <span style="color: #b1b100;">method</span><span style="color: #66cc66;">&#40;</span>n, <span style="color: #000000; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>n <span style="color: #66cc66;">&gt;</span> 1, n <span style="color: #66cc66;">*</span> fact<span style="color: #66cc66;">&#40;</span>n pred<span style="color: #66cc66;">&#41;</span>, 1<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
+<span style="color: #66cc66;">&gt;</span> fact:<span style="color: #b1b100;">method</span><span style="color: #66cc66;">&#40;</span>n, <span style="color: #000000; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>n <span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>, n <span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span>fact<span style="color: #66cc66;">&#40;</span>n pred<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Note how the REPL prints the method definition in a canonical form &#8211; it makes it obvious how Ioke parses the code, what are messages and what are arguments.</p>
<p>Let&#8217;s run our new factorial function:</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;">iik<span style="color: #66cc66;">&gt;</span> fact<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>
+<span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">6</span>
&nbsp;
iik<span style="color: #66cc66;">&gt;</span> fact<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>
+<span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">3628800</span>
&nbsp;
iik<span style="color: #66cc66;">&gt;</span> fact<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span>
+<span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">30414093201713378043612608166064768844377641568960512000000000000</span></pre></div></div>

<p>Ioke handles arbitrarily big numbers, so we don&#8217;t need to think about what fits in a certain number of bits.</p>
<p>The Iik REPL also comes with a simple debugger, which helps with handling conditions. For instance, let&#8217;s try to run the fact method, passing a message which doesn&#8217;t mean anything (yet):</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;">iik<span style="color: #66cc66;">&gt;</span> fact<span style="color: #66cc66;">&#40;</span>f<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">***</span> - couldn't find <span style="color: #000000; font-weight: bold;">cell</span> 'f' on 'Ground_0xC360E7' <span style="color: #66cc66;">&#40;</span><span style="color: #000066;">Condition</span> Error NoSuchCell<span style="color: #66cc66;">&#41;</span>
 f                                                <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&lt;</span>init<span style="color: #66cc66;">&gt;</span>:1:5<span style="color: #66cc66;">&#93;</span>
The following restarts are available:
 0: storeValue           <span style="color: #66cc66;">&#40;</span>Store value <span style="color: #000000; font-weight: bold;">for</span>: f<span style="color: #66cc66;">&#41;</span>
 1: useValue             <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">Use</span> value <span style="color: #000000; font-weight: bold;">for</span>: f<span style="color: #66cc66;">&#41;</span>
 2: abort                <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">restart</span>: abort<span style="color: #66cc66;">&#41;</span>
 3: quit                 <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">restart</span>: quit<span style="color: #66cc66;">&#41;</span>
&nbsp;
 dbg:<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1</span>
  dbg:<span style="color: #cc66cc;">1</span>:newValue<span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">5</span>
  +<span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">5</span>
&nbsp;
+<span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">120</span></pre></div></div>

<p>The above output shows that when we try to reference something that doesn&#8217;t exist we get a chance to provide that value. Here I decided to provide a value using the useValue restart and entered the value 5. This let the method continue executing and the result was printed.</p>
<p>To exit the REPL, just type: <code>exit</code></p>
<p>Next up are the Emacs modes for Ioke &#8211; stay tuned!</p>
<p>/M</p>
]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Hitchhiker&#8217;s Guide to an Ioke Dev Env From Source (part 4: Java+Ant)</title>
		<link>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-4/</link>
		<comments>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-4/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 22:08:43 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ioke]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=125</guid>
		<description><![CDATA[This is the fourth part in a series of posts for non-experts about setting up an Ioke development environment on Linux. Please see the previous posts to start at the beginning:

Part 1: Git
Part 2: Emacs
Part 3: emacs-starter-kit

It took a bit longer than anticipated to get to this point, as I got side tracked with the [...]]]></description>
			<content:encoded><![CDATA[<p>This is the fourth part in a series of posts for non-experts about setting up an Ioke development environment on Linux. Please see the previous posts to start at the beginning:</p>
<ul>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-1/">Part 1: Git</a></li>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-2/">Part 2: Emacs</a></li>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-3/">Part 3: emacs-starter-kit</a></li>
</ul>
<p>It took a bit longer than anticipated to get to this point, as I got side tracked with the <a href="http://martin.elwin.com/blog/2009/01/type-checking-in-ioke-java-methods/">Ioke type checking activities</a>. But now when <a href="http://ioke.org">Ioke S</a> is out we can continue with the series. So! We&#8217;re getting closer&#8230; Only a few more things to go.</p>
<h3>Installing Java</h3>
<p>As the current version of Ioke is implemented to run on a Java Virtual Machine, we need to get hold of one of those to be able to continue. The JVM brand we will install here is the latest stable one  produced by Sun.</p>
<p>What we need is Java SE Development Kit 6u11 for Linux, Multi-language, and the the filename for this is <code>jdk-6u11-linux-i586.bin</code>. Note that this is <em>not</em> the <code>.rpm.bin</code>, which is also available.</p>
<p>Download the file from <a href="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</a> (I&#8217;m sure you can find it) and put it in the <code>~/work</code> directory.</p>
<p>To unpack the file, let&#8217;s make it executable and then run it:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~$ cd ~/work
~/work$ cd ~/work                   
~/work$ chmod a+x jdk-6u11-linux-i586.bin 
~/work$ ./jdk-6u11-linux-i586.bin         
... lots of legalese here...</pre></div></div>

<p>Once the license agreement is accepted, the JVM will unpack itself into the directory <code>~/work/jdk1.6.0_11</code>. Let&#8217;s move it to where we want it and add <code>java</code> and <code>javac</code> to the <code>~/bin</code> directory as before:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work$ mv jdk1.6.0_11 ../opt
~/work$ cd ~/bin
~/bin$ ln -s ../opt/jdk1.6.0_11/bin/java
~/bin$ ln -s ../opt/jdk1.6.0_11/bin/javac</pre></div></div>

<p>And test it:</p>
<pre lang="sh>
~/bin$ java -version
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
</pre>
<p>That done &#8211; let&#8217;s move on to Ant.</p>
<h3>Ant</h3>
<p>Ioke uses <a href="http://ant.apache.org">Apache Ant</a> to handle the build process, so to build Ioke we need to get Ant installed.</p>
<p>Let&#8217;s download the Ant distributable package and unpack it in one go &#8211; as we did with Git:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/bin$ cd ~/opt
~/opt$ wget -O - http://www.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.tar.bz2 | tar xjv
&lt;/lang&gt;
&nbsp;
And add it to the ~/bin directory again so it's on the path:
&nbsp;
&lt;pre lang=&quot;sh&quot;&gt;
~/opt$ cd ~/bin
~/bin$ ln -s ../opt/apache-ant-1.7.1/bin/ant</pre></div></div>

<p>Let&#8217;s try it out:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/bin$ ant -version
Apache Ant version 1.7.1 compiled on June 27 2008</pre></div></div>

<p>Looking good!</p>
<p>Soon to come: How to get the Ioke source and build it.</p>
<p>/M</p>
<p><strong>Update:</strong> <a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-5/">Part 5: Ioke and the REPL</a></p>
]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Type Checking in Ioke Java Methods</title>
		<link>http://martin.elwin.com/blog/2009/01/type-checking-in-ioke-java-methods/</link>
		<comments>http://martin.elwin.com/blog/2009/01/type-checking-in-ioke-java-methods/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 07:15:06 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ioke]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=132</guid>
		<description><![CDATA[Ola Bini recently issued a call to arms to help with the receiver and argument validation for Java methods in Ioke. These are the Ioke methods that are implemented in Java, instead of in Ioke itself.
The Java methods usually operate on the specific data contained within Ioke objects. This data corresponds to different Java classes, [...]]]></description>
			<content:encoded><![CDATA[<p>Ola Bini recently issued <a href="http://kenai.com/projects/ioke/lists/dev/archive/2009-01/message/21">a call to arms</a> to help with the receiver and argument validation for Java methods in Ioke. These are the Ioke methods that are implemented in Java, instead of in Ioke itself.</p>
<p>The Java methods usually operate on the specific data contained within Ioke objects. This data corresponds to different Java classes, depending on what the Ioke object should hold. For instance, an Ioke List contains inside the data area a Java List. To operate on this List the Java code needs to get hold of the List reference &#8211; and it does this in a lot of cases by assuming the data object is of a certain type and casts to this type. If the data object is of a different type then a Java <code>ClassCastException</code> is thrown, which makes the interpreter quit.</p>
<p>Since Ola mailed the call to arms a number of things have happened. A few people (including myself) have volunteered to help out with adding the validation code. Additionally, a few supporting methods and additions have been added to the Ioke code base to simplify adding type checks to the existing code. And it&#8217;s these additions that I will talk about here.</p>
<h3>Current Code</h3>
<p>As an example what the new type validations can look like I will use the <code>List +</code> method that Ola also mentioned in the example.</p>
<p>This is the previous code from <a href="http://github.com/olabini/ioke/blob/e3018142943253f0fd13a967ffb68d39087d9600/src/main/ioke/lang/IokeList.java">IokeList.java</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">obj.<span style="color: #006633;">registerMethod</span><span style="color: #009900;">&#40;</span>runtime.<span style="color: #006633;">newJavaMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;returns a new list that contains the receivers elements and the elements of the list sent in as the argument.&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> JavaMethod<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;+&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> DefaultArgumentsDefinition ARGUMENTS <span style="color: #339933;">=</span> DefaultArgumentsDefinition
            .<span style="color: #006633;">builder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">withRequiredPositional</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;otherList&quot;</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">getArguments</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> DefaultArgumentsDefinition getArguments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> ARGUMENTS<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> activate<span style="color: #009900;">&#40;</span>IokeObject method, IokeObject context, IokeObject message, <span style="color: #003399;">Object</span> on<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ControlFlow <span style="color: #009900;">&#123;</span>
            List<span style="color: #339933;">&lt;</span>Object<span style="color: #339933;">&gt;</span> args <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Object<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            getArguments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getEvaluatedArguments</span><span style="color: #009900;">&#40;</span>context, message, on, args, <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            List<span style="color: #339933;">&lt;</span>Object<span style="color: #339933;">&gt;</span> newList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Object<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            newList.<span style="color: #006633;">addAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>IokeList<span style="color: #009900;">&#41;</span>IokeObject.<span style="color: #006633;">data</span><span style="color: #009900;">&#40;</span>on<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            newList.<span style="color: #006633;">addAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>IokeList<span style="color: #009900;">&#41;</span>IokeObject.<span style="color: #006633;">data</span><span style="color: #009900;">&#40;</span>args.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>0<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">return</span> context.<span style="color: #006633;">runtime</span>.<span style="color: #006633;">newList</span><span style="color: #009900;">&#40;</span>newList, IokeObject.<span style="color: #006633;">as</span><span style="color: #009900;">&#40;</span>on<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>New Type Checks</h3>
<p>The key to the new validation are two new classes, which extend the functionality of the normal <code>JavaMethod</code> class with type checking functionality. These are:</p>
<ul>
<li><a href="http://github.com/olabini/ioke/blob/0e20b492b8e057e9d2c006698deca02ebf8f45f7/src/main/ioke/lang/TypeCheckingArgumentsDefinition.java">TypeCheckingArgumentsDefinition</a></li>
<li><a href="http://github.com/olabini/ioke/blob/0e20b492b8e057e9d2c006698deca02ebf8f45f7/src/main/ioke/lang/TypeCheckingJavaMethod.java">TypeCheckingJavaMethod</a></li>
</ul>
<p>When using these to define the Java method we can &#8220;annotate&#8221; the arguments definition with types for both the arguments and the receiver. By then implementing the appropriate <code>activate(...)</code> the super class takes care of evaluating and validating (converting as appropriate) the receiver and arguments.</p>
<p>For instance, for the <code>List +</code> example, the above code gets changed to the following:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">obj.<span style="color: #006633;">registerMethod</span><span style="color: #009900;">&#40;</span>runtime.<span style="color: #006633;">newJavaMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;returns a new list that contains the receivers elements and the elements of the list sent in as the argument.&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> TypeCheckingJavaMethod<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;+&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> TypeCheckingArgumentsDefinition ARGUMENTS <span style="color: #339933;">=</span> TypeCheckingArgumentsDefinition
            .<span style="color: #006633;">builder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">receiverMustMimic</span><span style="color: #009900;">&#40;</span>runtime.<span style="color: #006633;">list</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">withRequiredPositional</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;otherList&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">whichMustMimic</span><span style="color: #009900;">&#40;</span>runtime.<span style="color: #006633;">list</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">getArguments</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> TypeCheckingArgumentsDefinition getArguments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> ARGUMENTS<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> activate<span style="color: #009900;">&#40;</span>IokeObject self, <span style="color: #003399;">Object</span> on, List<span style="color: #339933;">&lt;</span>Object<span style="color: #339933;">&gt;</span> args, Map<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span> keywords, IokeObject context, IokeObject message<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ControlFlow <span style="color: #009900;">&#123;</span>
            List<span style="color: #339933;">&lt;</span>Object<span style="color: #339933;">&gt;</span> newList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Object<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            newList.<span style="color: #006633;">addAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>IokeList<span style="color: #009900;">&#41;</span>IokeObject.<span style="color: #006633;">data</span><span style="color: #009900;">&#40;</span>on<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            newList.<span style="color: #006633;">addAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>IokeList<span style="color: #009900;">&#41;</span>IokeObject.<span style="color: #006633;">data</span><span style="color: #009900;">&#40;</span>args.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>0<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">return</span> context.<span style="color: #006633;">runtime</span>.<span style="color: #006633;">newList</span><span style="color: #009900;">&#40;</span>newList, IokeObject.<span style="color: #006633;">as</span><span style="color: #009900;">&#40;</span>on<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Note that most of the boiler plate code for arguments handling (which most JavaMethods do) is removed, leaving a clean implementation of the necessary logic &#8211; to concatenate two lists in this case.</p>
<p>A few things are done:</p>
<ol>
<li>The JavaMethod is changed to TypeCheckingJavaMethod</li>
<li>The arguments definition is changed to a TypeCheckingArgumentsDefinition</li>
<li>The appropriate types are added to the arguments definition</li>
<li>Return type of getArguments is changed to TypeCheckingArgumentsDefinition</li>
<li>The active method is changed to the one which gets the arguments list and keywords</li>
<li>The manual call to getArguments().getEvaluatedArguments() is removed as we now get the arguments passed</li>
</ol>
<p>The relevant tests for this, which should be added to the <code>list_spec.ik</code> test file, could look like:</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;">describe<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">List</span>,
  describe<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;+&quot;</span>, 
    it<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;should validate type of receiver&quot;</span>,
      x = <span style="color: #000066;">Origin</span> <span style="color: #b1b100;">mimic</span>
      x <span style="color: #000000; font-weight: bold;">cell</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;+&quot;</span><span style="color: #66cc66;">&#41;</span> = <span style="color: #000000; font-weight: bold;">List</span> <span style="color: #000000; font-weight: bold;">cell</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;+&quot;</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">fn</span><span style="color: #66cc66;">&#40;</span>x + <span style="color: #66cc66;">&#91;</span>3<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> should signal<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">Condition</span> Error Type IncorrectType<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#41;</span>
&nbsp;
    it<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;should validate type of argument&quot;</span>,
      <span style="color: #b1b100;">fn</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>1,2,3<span style="color: #66cc66;">&#93;</span> + 3<span style="color: #66cc66;">&#41;</span> should signal<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">Condition</span> Error Type IncorrectType<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>So for you to do:</p>
<ol>
<li>Fork Ioke</li>
<li>Pick a <code>IokeData</code> subclass which no one has started on yet (check with Ola/naeu/me in the IRC channel #ioke on FreeNode)</li>
<li>Identify a method which makes faulty assumptions on receiver or arguments</li>
<li>Add a test as per the above to validate the arguments and receiver</li>
<li>Change <code>JavaMethod</code> implementation as per the above to fix the test</li>
<li>Commit test and fix in togther to your fork</li>
<li>Rinse and repeat until the whole file is done</li>
<li>Convince Ola to pull your fork</li>
</ol>
<p>Let&#8217;s get crackin&#8217;!</p>
<p>(but first &#8211; back to normal work&#8230; :)</p>
<p>/M</p>
]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2009/01/type-checking-in-ioke-java-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Hitchhiker’s Guide to an Ioke Dev Env From Source (part 3: emacs-starter-kit)</title>
		<link>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-3/</link>
		<comments>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-3/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 21:46:57 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[ioke]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=103</guid>
		<description><![CDATA[This is the third part in a series of posts for non-experts about setting up an Ioke development environment on Linux. Please see the previous posts to start at the beginning:

Part 1: Git
Part 2: Emacs

The emacs-starter-kit is a set of base configuration for Emacs. It contains a number of useful elisp libraries, with a slight [...]]]></description>
			<content:encoded><![CDATA[<p>This is the third part in a series of posts for non-experts about setting up an Ioke development environment on Linux. Please see the previous posts to start at the beginning:</p>
<ul>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-1/">Part 1: Git</a></li>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-2/">Part 2: Emacs</a></li>
</ul>
<p>The <a href="http://github.com/technomancy/emacs-starter-kit/tree/master">emacs-starter-kit</a> is a set of base configuration for Emacs. It contains a number of useful elisp libraries, with a slight focus on dynamic languages.</p>
<p>To install it, perform the following steps (note that we move any existing Emacs configuration out of the way first to avoid stomping what you currently have):</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work/emacs$ cd
~$ mv .emacs.d .emacs.d.old
~$ mv .emacsrc .emacsrc.old
~$ git clone git://github.com/technomancy/emacs-starter-kit.git .emacs.d</pre></div></div>

<p>If you now start Emacs again you&#8217;ll see that the menu bar and the toolbar is gone. This is the default in emacs-starter-kit as most Emacs users don&#8217;t find them useful. For new users the menu bar can sometimes come in handy, to get it back temporarily, just press <code>F1</code>.</p>
<h3>Configuring Emacs</h3>
<p>If you want to add your own customizations to Emacs when using emacs-starter-kit, just add an Emacs LISP file called <code><em>username</em>.el</code>, or <code><em>hostname</em>.el</code>, in the <code>~/.emacs.d</code> directory. For instance, to make the menu bar always visible:</p>
<ol>
<li>Open Emacs, if it&#8217;s not open already.</li>
<li>Press <code>C-x C-f</code> and type in: <code>~/.emacs.d/<em>username</em>.el</code><br />Where <em>username</em> is the name you log in with (for instance, in my case the complete filename is <code>melwin.el</code>).</li>
<li>Type in the following in the file:

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>menu-bar-mode <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

</li>
<li>And save the file with <code>C-x s</code>.</li>
<li>Now quit (<code>C-x c</code>) and restart and you&#8217;ll see that the menu bar is shown.</li>
</ol>
<h3>Working with Magit</h3>
<p>emacs-starter-kit includes, among many other things, the very nice <a href="http://zagadka.vm.bytemark.co.uk/magit/magit.html">Magit Git mode for Emacs</a>, which gives you a nice interface for working with a Git repository.</p>
<p>Let&#8217;s use this mode to commit our recent changes to the configuration file to our local clone of the <code>emacs-starter-kit</code> repository. This helps us track changes we make and also makes a backup of the file in case we screw (sorry, mess) something up.</p>
<p><strong>Note 1:</strong> To move easily between Emacs windows using the keyboard, just press <code>Shift</code> and the arrow key pointing in the direction you want to move.<br />
<strong>Note 2:</strong> To only show the current Emacs window &#8211; press: <code>C-x 1</code></p>
<ol>
<li>Inside Emacs, press <code>C-x g</code> to run <code>magit-status</code> and enter the directory (note that <code>Tab</code> auto-completes): <code>~/.emacs.d</code><br />
        <img src="http://martin.elwin.com/blog/wp-content/uploads/2009/01/emacs-magit-status.png" alt="Emacs magit-status" title="Emacs magit-status" width="694" height="353" class="alignnone size-full wp-image-114" />
        </li>
<li>Put the cursor over the <code><em>username</em>.el</code> in the list of <code>Untracked files</code>.</li>
<li>Press <code>s</code> to Stage the new file &#8211; this adds the file to the Git staging area, from which all files are committed.<br />
<img src="http://martin.elwin.com/blog/wp-content/uploads/2009/01/emacs-magit-status-staged.png" alt="Emacs magit-status staged" title="Emacs magit-status staged" width="694" height="353" class="alignnone size-full wp-image-115" />
</li>
<li>Press <code>d</code> and then accept to diff against HEAD &#8211; this will show you a diff view of the changes we have staged &#8211; just the add of a single file.<br />
<img src="http://martin.elwin.com/blog/wp-content/uploads/2009/01/emacs-magit-status-diff.png" alt="Emacs magit-status diff" title="Emacs magit-status diff" width="757" height="429" class="alignnone size-full wp-image-116" />
</li>
<li>Press <code>c</code> to perform the commit. This opens a new buffer into which a commit message can be added.</li>
<li>Write something like: <code>Add personal configuration file.</code></li>
<li>Now press <code>C-c C-c</code> to commit the file.</li>
</ol>
<p>That&#8217;s it &#8211; now the change has been committed to the local clone of the emacs-starter-kit Git repository.</p>
<p>To see the log of all commits, press <code>l</code> (lowercase L) in the <code>magit-status</code> buffer:<br />
<img src="http://martin.elwin.com/blog/wp-content/uploads/2009/01/emacs-magit-status-log.png" alt="Emacs magit-status log" title="Emacs magit-status log" width="757" height="429" class="alignnone size-full wp-image-121" /></p>
<p>To look at a certain commit &#8211; just press <code>Enter</code> on it and a view of the diff will be shown. This makes it quite easy to browse through commits in a repository. At the top of the log is the most recent commit, which in this case is the file we just added.</p>
<p>To update emacs-starter-kit with the latest changes in the GitHub repository, just press <code>F</code> in the <code>magit-status</code> buffer or run <code>git pull</code> in the <code>~/.emacs.d</code> directory.</p>
<h3>Summary</h3>
<p>Now that we have Git and Emacs set up we can finally move to Ioke. In the next post we&#8217;ll go through installing the latest Java JDK and getting and compiling the Ioke source code.</p>
<p>Join me then!</p>
<p>/M</p>
<p><strong>Update:</strong> <a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-4/">Part 4: Java and Ant</a></p>
]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Hitchhiker’s Guide to an Ioke Dev Env From Source (part 2: Emacs)</title>
		<link>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-2/</link>
		<comments>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-2/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 23:10:59 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ioke]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=88</guid>
		<description><![CDATA[This is the second part in a series of posts for non-experts about setting up an Ioke development environment on Linux. Please see the previous post to start at the beginning:

Part 1: Git

In this post we will install GNU Emacs from source and also get a basic configuration set up using the emacs-starter-kit.
If you already [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second part in a series of posts for non-experts about setting up an Ioke development environment on Linux. Please see the previous post to start at the beginning:</p>
<ul>
<li><a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-1/">Part 1: Git</a></li>
</ul>
<p>In this post we will install GNU Emacs from source and also get a basic configuration set up using the <a href="http://github.com/technomancy/emacs-starter-kit/tree/master">emacs-starter-kit</a>.</p>
<p>If you already have Emacs installed and have an old configuration laying around you probably want to make a backup of this before following the below instructions. This post assumes that there is no Emacs installed and that the user doesn&#8217;t have any Emacs configuration in the home directory.</p>
<h3>Installing Emacs</h3>
<p>Git is an efficient Distributed Version Control System. Although the primary VCS for Emacs is still CVS &#8211; and it looks like they are moving towards Bazaar &#8211; we&#8217;ll get the Emacs sources from the <a href="Emacs Git mirror">Emacs Git mirror</a>. We want to be <a href="http://www.unethicalblogger.com/posts/2009/01/im_using_git_because_it_makes_me_feel_cool">cool</a>, right?</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~$ cd work
~/work$ git clone --depth 1 git://git.sv.gnu.org/emacs.git
Initialized empty Git repository in /home/melwin/work/emacs/.git/
remote: Counting objects: 46400, done.
remote: Compressing objects: 100% (24410/24410), done.
remote: Total 46400 (delta 41204), reused 25501 (delta 21836)
Receiving objects: 100% (46400/46400), 74.38 MiB | 213 KiB/s, done.
Resolving deltas: 100% (41204/41204), done.
Checking out files: 100% (2837/2837), done.</pre></div></div>

<p>With the <code>--depth 1</code> parameter we limit the history so that we only get the latest version of the files &#8211; in this case we&#8217;re not interested in the full history.</p>
<p><strong>Note:</strong> As we&#8217;re getting the bleeding edge source code of Emacs, it could happen that the build is broken. I&#8217;ve never had this happen on me, but in case you get strange errors when building Emacs, this might be the reason. Usually such problems are fixed quickly, so try to do a <code>git pull</code> a bit later to update the downloaded source.</p>
<p>Previously, to get fun things like <a href="http://www.emacswiki.org/emacs/MultiTTYSupport">multi-tty support</a> and <a href="http://www.emacswiki.org/emacs/XftGnuEmacs">smooth fonts</a>, we had to get specific feature branches of Emacs. Nowadays, however, all the things we want are merged into the Emacs master branch. Before building, the only thing we need to do is to make sure the necessary development libraries are installed. In case you wonder how I came up with this list: the good ol&#8217; method of trial and error. I simply ran the <code>configure</code> command and checked the error messages. This helped me identify the needed libraries. Now you can reap the benefits by just doing the following:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work$ sudo apt-get install libgtk2.0-dev libxpm-dev libjpeg-dev libgif-dev libtiff-dev
...</pre></div></div>

<p>&#8230; and then run the classical <code>configure</code>, <code>make</code> and <code>make install</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work$ cd emacs
~/work/emacs$ ./configure --prefix=$HOME/opt/emacs-23.0.60
...
~/work/emacs$ make
...
~/work/emacs$ make install
...</pre></div></div>

<p>Phew. That burned som CPU cycles&#8230;! Once done &#8211; let&#8217;s add it to our <code>bin</code> directory, just as we did with Git.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work/emacs$ cd ~/bin
~/bin$ ln -s ../opt/emacs-23.0.60/bin/emacs
~/bin$ ln -s ../opt/emacs-23.0.60/bin/emacsclient
~/bin$ ls
emacs  emacsclient  git</pre></div></div>

<p>Time to test. Just run emacs:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/bin% emacs</pre></div></div>

<p>This should show you an Emacs window with a pretty(?) GNU.</p>
<p><img src="http://martin.elwin.com/blog/wp-content/uploads/2009/01/emacs-window.png" alt="Emacs Window" title="Emacs Window" width="694" height="671" class="alignnone size-full wp-image-89" /></p>
<p>If you&#8217;re completely new to Emacs, this might be a good opportunity to run the Emacs tutorial. Emacs is a self-documenting editor, which means that most things that you might want to learn about Emacs can be found inside the editor itself &#8211; including information about internal functions and libraries.</p>
<p>To run the tutorial, just press <code>Ctrl+h t</code> (that is, <code>control</code> and <code>h</code>, release control, then press <code>t</code>), or, in Emacs lingo, <code>C-h t</code> (which is the convention I&#8217;ll use from now on).</p>
<p>Once you&#8217;ve learned enough (you did complete the whole thing, right?), just quit using <code>C-x c</code>.</p>
<p><strong>Note:</strong> To update the source code and rebuild, do a <code>git pull</code> in the <code>emacs</code> directory, then <code>make distclean</code> (in case some build files changed) and then perform the compile and installation as per the above again.</p>
<p>Next up is <code>emacs-starter-kit</code> to get more functionality in Emacs and a decent default configuration to help us get going &#8211; stay tuned!</p>
<p>/M</p>
<p><strong>Update:</strong> <a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-3/">Part 3: emacs-starter-kit</a></p>
]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Hitchhiker’s Guide to an Ioke Dev Env From Source (part 1: Git)</title>
		<link>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-1/</link>
		<comments>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-1/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 19:35:36 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ioke]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=74</guid>
		<description><![CDATA[In this series of posts I will guide you, the humble reader, through the install procedure to get a development environment for Ioke up and running. All the cool kids want to develop in Ioke nowadays, so let&#8217;s make you can as well!
The components we will be installing are:

Git 1.6.1
Emacs (latest snapshot) with emacs-starter-kit
Java JDK [...]]]></description>
			<content:encoded><![CDATA[<p>In this series of posts I will guide you, the humble reader, through the install procedure to get a development environment for <a href="http://ioke.org/">Ioke</a> up and running. All the cool kids want to develop in Ioke nowadays, so let&#8217;s make you can as well!</p>
<p>The components we will be installing are:</p>
<ul>
<li><a href="http://git-scm.com/">Git 1.6.1</a></li>
<li><a href="http://www.gnu.org/software/emacs/">Emacs (latest snapshot)</a> with <a href="http://github.com/technomancy/emacs-starter-kit/tree/master">emacs-starter-kit</a></li>
<li><a href="http://java.sun.com/">Java JDK 1.6</a></li>
<li><a href="http://ioke.org/">Ioke (latest snapshot)</a></li>
</ul>
<p>These instructions are written for a non-expert who might not have too much experience with compiling things, using Git or Emacs. If you&#8217;re an expert you will find nothing new or exciting here! The environment I use is a freshly installed <a href="http://www.kubuntu.org/">Kubuntu Intrepid Ibex</a> box, although most of it should be similar, if not identical, to other Ubuntu/Debian based distributions.</p>
<p>The components listed above will all be installed manually &#8211; not using the package system. This is to allow us to get the freshest versions of what we need without depending on the packages in the distribution to be updated (or hunted down in alternative repositories). The only thing we will install from the distribution are the compilers, tools and development libraries used to compile the software.</p>
<p>Why do we not use the package system? Well, that&#8217;s a valid question. Most of the above can be installed from packages in custom repositories. It&#8217;s simple and convenient. However here we will not use if for two reasons:</p>
<ol>
<li>If packages are used we will depend on the repositories to be updated to use the latest version of some software, which can be annoying if we want to develop on the bleeding edge.</li>
<li>It&#8217;s good to know how to compile things yourself &#8211; so by not using prepared packages we might learn something!</li>
</ol>
<p>To keep control over our custom built software we&#8217;ll install it in dedicated directories under <code>$HOME/opt</code> instead of in the normal locations like <code>/usr/bin</code>. This allows us to get everything installed without needing root access (except to install the compilers etc from the distribution).</p>
<h3>First Step</h3>
<h1>Don&#8217;t Panic!</h1>
<p>Always sound advice to start with &#8211; especially if you are hitchhiking. I&#8217;m going to try to cover each step in detail, but if you think something is unclear &#8211; just leave a comment and I&#8217;ll try to clarify. So &#8211; grab your towel and let&#8217;s get going!</p>
<h3>Install Git</h3>
<p>For Emacs, emacs-starter-kit and Ioke we will use Git to retrieve the sources. Therefore the first thing we need to install is Git.</p>
<p>In the command line instructions below, all lines prefixed by the prompt <code>&lt;dir&gt;$</code> are commands to be typed in. The rest are output or my comments.</p>
<p>Open a terminal window and create a new work directory under your home using the following instructions. In this directory we will work with downloaded source files and build the software.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~$ mkdir ~/work
~/work$ cd ~/work
~/work$ wget -O - http://kernel.org/pub/software/scm/git/git-1.6.1.tar.bz2 | tar xjv
... many lines...</pre></div></div>

<p>The last command downloads the git source package and expands it in one go by piping it directly from <code>wget</code> to <code>tar</code>, which is told to expand it using bz2 with the <code>j</code> parameter. This is a convenient way to get packages off the net and unpacked, especially when there is no need to keep the package itself around.</p>
<p>The result is that we now have a <code>git-1.6.1</code> directory in the work directory. Let&#8217;s see how we compile it:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work$ cd git-1.6.1/
~/work/git-1.6.1$ head INSTALL
&nbsp;
                Git installation
&nbsp;
Normally you can just do &quot;make&quot; followed by &quot;make install&quot;, and that
will install the git programs in your own ~/bin/ directory.  If you want
to do a global install, you can do
&nbsp;
        $ make prefix=/usr all doc info ;# as yourself
        # make prefix=/usr install install-doc install-html install-info ;# as root
&nbsp;
~/work/git-1.6.1$</pre></div></div>

<p>So &#8211; two commands. Simple enough! However, before we compile &#8211; we need to make sure all the relevant packages are installed:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work/git-1.6.1$ sudo apt-get install libcurl4-openssl-dev zlib1g-dev libexpat-dev tk8.5 asciidoc docbook2x</pre></div></div>

<p>Depending on your internet connection, this could take quite a while, as we need to download the <code>texlive</code> distribution, among other things, to build all of the Git documentation. This is not strictly necessary, but here we&#8217;ll just do it for completeness&#8217; sake.</p>
<p>Let&#8217;s build git and make sure it&#8217;s installed under our <code>$HOME/opt</code> directory as we said in the beginning:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work/git-1.6.1$ make prefix=~/opt/git-1.6.1 all doc info
... lots of lines...</pre></div></div>

<p>Compiling Git will take some time as well. Go get a coffee (or perhaps a <a href="http://en.wikibooks.org/wiki/Bartending/Cocktails/Pan_Galactic_Gargle_Blaster">Pan Galactic Gargle Blaster</a> &#8211; sweet like nectar).</p>
<p>Once the compile is done &#8211; install it. Note that we don&#8217;t need to do this as <code>root</code> as we&#8217;re installing under the user home directory:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work/git-1.6.1$ make prefix=~/opt/git-1.6.1 install install-doc install-html install-info</pre></div></div>

<p>Let&#8217;s add it to the user&#8217;s path by linking it into the private <code>bin</code> directory. This depends on the standard Ubuntu <code>bash</code> shell profile script which adds <code>~/bin</code> to the <code>PATH</code> variable. If a different shell is used you need to perform the appropriate steps yourself.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/work/git-1.6.1$ mkdir ~/bin
~/work/git-1.6.1$ cd !$
~/bin$ ln -s ../opt/git-1.6.1/bin/git</pre></div></div>

<p>Now close the shell/terminal, open a new one &#8211; and try the <code>git</code> command:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~$ git --version
git version 1.6.1</pre></div></div>

<p>If you get the above output &#8211; great! You&#8217;re don! Sit back and relax for a bit before moving on to the next section.</p>
<p>However, if you don&#8217;t get the version output, but instead see the following message, review the previous instructions and make sure it works ok before continuing.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">#INCORRECT OUTPUT - SOMETHING WAS MISSED!
#GO BACK AND REVIEW
~$ git                                                                                                                                                                                        
The program 'git' is currently not installed.  You can install it by typing:                                                                                                                  
sudo apt-get install git-core                                                                                                                                                                 
-bash: git: command not found</pre></div></div>

<p>If you still can&#8217;t get it to work &#8211; drop me a comment!</p>
<h3>Git in 30 Seconds</h3>
<p>There are loads of good Git tutorials and information. You can find several on the <a href="http://git-scm.com/documentation">official Git page</a> and at <a href="http://github.com/guides/home">GitHub</a> (go sign up if you haven&#8217;t already, and <a href="http://github.com/melwin">fork me</a>!).</p>
<p>Here is a quick run through of a few common Git commands you could try out with your freshly brewed cup of Git:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~$ cd
~$ mkdir gittest
~$ cd gittest/
~/gittest$ git init
Initialized empty Git repository in /home/melwin/gittest/.git/
~/gittest$ echo Test file! &gt; test.txt
~/gittest$ git add test.txt
~/gittest$ git commit -m &quot;Initial import.&quot;
[master (root-commit)]: created 79c091d: &quot;Initial import.&quot;
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test.txt
~/gittest$ echo Add line. &gt;&gt; test.txt
~/gittest$ git diff test.txt
diff --git a/test.txt b/test.txt
index 1cbaf90..3746f9e 100644
--- a/test.txt
+++ b/test.txt
@@ -1 +1,2 @@
 Test file!
+Add line.
~/gittest$ git commit -a -m &quot;Add new line.&quot;
[master]: created b20f9a4: &quot;Add new line.&quot;
 1 files changed, 1 insertions(+), 0 deletions(-)</pre></div></div>

<p>If you can follow the above &#8211; great! First part finished. Next up is to install GNU Emacs from source and the emacs-starter-kit, which provides a decent default a set of configuration for Emacs.</p>
<p>Stay tuned!</p>
<p>/M</p>
<p><strong>Update:</strong> <a href="http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-2/">Part 2: Emacs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2009/01/the-hitchhikers-guide-to-an-ioke-dev-env-from-source-part-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ioke Syntax Highlighter for GeSHi</title>
		<link>http://martin.elwin.com/blog/2009/01/ioke-syntax-highlighter-for-geshi/</link>
		<comments>http://martin.elwin.com/blog/2009/01/ioke-syntax-highlighter-for-geshi/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 22:53:07 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[geshi]]></category>
		<category><![CDATA[ioke]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=56</guid>
		<description><![CDATA[Speaking of Ioke &#8211; just added a syntax highlighter definition for GeSHi in my Ioke fork repository. The commit can be found here:
http://github.com/melwin/ioke/commit/54cfd7e54de0be910385c6ec805693fd3ed4e294
The keyword definitions I borrowed (read stole) from Sam Aaron&#8217;s TextMate bundle (also in the Ioke repository). As Sam just said in the #ioke on freenode: &#8220;what goes around comes around&#8221;. :)
Highlighting test:

 [...]]]></description>
			<content:encoded><![CDATA[<p>Speaking of Ioke &#8211; just added a syntax highlighter definition for GeSHi in my Ioke fork repository. The commit can be found here:</p>
<p><a href="http://github.com/melwin/ioke/commit/54cfd7e54de0be910385c6ec805693fd3ed4e294">http://github.com/melwin/ioke/commit/54cfd7e54de0be910385c6ec805693fd3ed4e294</a></p>
<p>The keyword definitions I borrowed (read stole) from <a href="http://sam.aaron.name/">Sam Aaron</a>&#8217;s TextMate bundle (also in the Ioke repository). As Sam just said in the #ioke on freenode: &#8220;what goes around comes around&#8221;. :)</p>
<p>Highlighting test:</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;">    m = <span style="color: #006600;">#/<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>areaCode<span style="color: #66cc66;">&#125;</span>\d<span style="color: #66cc66;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>-<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>localNumber<span style="color: #66cc66;">&#125;</span>\d<span style="color: #66cc66;">&#123;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span></span> =~ <span style="color: #000066;">number</span>
&nbsp;
    describe<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;start&quot;</span>,
      it<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;should return the start index of group zero, which is the whole group&quot;</span>,
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/foo/</span> =~ <span style="color: #ff0000;">&quot;foobar&quot;</span><span style="color: #66cc66;">&#41;</span> start should == 0
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/foo/</span> =~ <span style="color: #ff0000;">&quot;abcfoobar&quot;</span><span style="color: #66cc66;">&#41;</span> start should == 3
&nbsp;
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/foo/</span> =~ <span style="color: #ff0000;">&quot;foobar&quot;</span><span style="color: #66cc66;">&#41;</span> start<span style="color: #66cc66;">&#40;</span>0<span style="color: #66cc66;">&#41;</span> should == 0
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/foo/</span> =~ <span style="color: #ff0000;">&quot;abcfoobar&quot;</span><span style="color: #66cc66;">&#41;</span> start<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> should == <span style="color: #cc66cc;">3</span>
      <span style="color: #66cc66;">&#41;</span>
&nbsp;
      it<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;should return the start index of another group&quot;</span>,
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/<span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span></span> =~ <span style="color: #ff0000;">&quot;fooab cd efbar&quot;</span><span style="color: #66cc66;">&#41;</span> start<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> should == <span style="color: #cc66cc;">6</span>
      <span style="color: #66cc66;">&#41;</span>
&nbsp;
      it<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;should return the start index from the name of a named group&quot;</span>,
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>one<span style="color: #66cc66;">&#125;</span>..<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>two<span style="color: #66cc66;">&#125;</span>..<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>three<span style="color: #66cc66;">&#125;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span></span> =~ <span style="color: #ff0000;">&quot;fooab cd efbar&quot;</span><span style="color: #66cc66;">&#41;</span> start<span style="color: #66cc66;">&#40;</span>:two<span style="color: #66cc66;">&#41;</span> should == <span style="color: #cc66cc;">6</span>
      <span style="color: #66cc66;">&#41;</span>
&nbsp;
      it<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;should return -1 for a group that wasn't matched&quot;</span>,
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/<span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>?<span style="color: #66cc66;">/</span></span> =~ <span style="color: #ff0000;">&quot;ab&quot;</span><span style="color: #66cc66;">&#41;</span> start<span style="color: #66cc66;">&#40;</span>2<span style="color: #66cc66;">&#41;</span> should == -1
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>no<span style="color: #66cc66;">&#125;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>way<span style="color: #66cc66;">&#125;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>?<span style="color: #66cc66;">/</span></span> =~ <span style="color: #ff0000;">&quot;ab&quot;</span><span style="color: #66cc66;">&#41;</span> start<span style="color: #66cc66;">&#40;</span>:way<span style="color: #66cc66;">&#41;</span> should == -1
&nbsp;
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/<span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>?<span style="color: #66cc66;">/</span></span> =~ <span style="color: #ff0000;">&quot;ab&quot;</span><span style="color: #66cc66;">&#41;</span> start<span style="color: #66cc66;">&#40;</span>10<span style="color: #66cc66;">&#41;</span> should == -1
        <span style="color: #66cc66;">&#40;</span><span style="color: #006600;">#/<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>no<span style="color: #66cc66;">&#125;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>way<span style="color: #66cc66;">&#125;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>?<span style="color: #66cc66;">/</span></span> =~ <span style="color: #ff0000;">&quot;ab&quot;</span><span style="color: #66cc66;">&#41;</span> start<span style="color: #66cc66;">&#40;</span>:blarg<span style="color: #66cc66;">&#41;</span> should == -<span style="color: #cc66cc;">1</span>
      <span style="color: #66cc66;">&#41;</span>
&nbsp;
      it<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;should validate type of receiver&quot;</span>,
        <span style="color: #000066;">Regexp</span> Match should checkReceiverTypeOn<span style="color: #66cc66;">&#40;</span>:start<span style="color: #66cc66;">&#41;</span>
      <span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#41;</span>
&nbsp;
    x = #<span style="color: #66cc66;">/</span>bla #<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;foo&quot;</span><span style="color: #66cc66;">&#125;</span> bar<span style="color: #66cc66;">/</span></pre></div></div>

<p>/M</p>
]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2009/01/ioke-syntax-highlighter-for-geshi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple JSON Parser in Ioke</title>
		<link>http://martin.elwin.com/blog/2009/01/simple-json-parser-in-ioke/</link>
		<comments>http://martin.elwin.com/blog/2009/01/simple-json-parser-in-ioke/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 22:35:47 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ioke]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=39</guid>
		<description><![CDATA[After having enjoyed most of the days off over Christmas my fingers started itching &#8211; time to do some programming. Luckily around the same time I stumbled across Ola Bini&#8217;s posts on the Ioke language. As the Ioke guide begins:

Ioke is a general purpose language. It is a strongly typed, extremely dynamic, prototype object oriented [...]]]></description>
			<content:encoded><![CDATA[<p>After having enjoyed most of the days off over Christmas my fingers started itching &#8211; time to do some programming. Luckily around the same time I stumbled across <a href="http://olabini.com/blog/category/ioke/">Ola Bini&#8217;s posts on the Ioke language</a>. As the <a href="http://ioke.org/guide.html">Ioke guide</a> begins:</p>
<blockquote><p>
Ioke is a general purpose language. It is a strongly typed, extremely dynamic, prototype object oriented language. It is homoiconic and it&#8217;s closest ancestors is Io, Smalltalk, Ruby and Lisp &#8211; but it&#8217;s quite a distance from all of them.
</p></blockquote>
<p>So what does this all mean? It means it&#8217;s fun! The language syntax is very regular (although not quite as regular as lisp) &#8211; code is data, data is code and everything is a message. It&#8217;s also one of relatively few languages that provide macros similar to those in lisp. In Ioke this means that a message stream can be operated on (modified, transformed, etc) before it&#8217;s evaluated, using normal Ioke methods. Anyone who groks lisp should be familiar with the power this gives.</p>
<p>In Ioke, a chain of messages is separated by space, with the first message being sent to the current receiver and subsequent messages are sent to the result of the previous one. For instance, in the code</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;"><span style="color: #ff0000;">&quot;ioke rocks&quot;</span> upper <span style="color: #000000; font-weight: bold;">println</span></pre></div></div>

<p>the text literal &#8220;ioke rocks&#8221; results in an internal message which creates a Text object. To this object the <code>upper</code> messages is sent, which results in an upper case copy of the Text object is created. To this object the <code>println</code> message is sent, which prints the upper case text to the console.</p>
<p>As the Ioke reader handles space separated tokens, it&#8217;s quite easy to create macros to process non Ioke code. As a learning exercise I decided to try to implement a <a href="http://www.json.org/">JSON</a> parser. Nothing too fancy &#8211; and doesn&#8217;t even have to be secure &#8211; just enough to parse simple JSON into Ioke objects.</p>
<p>JSON is usually parsed in one of two ways &#8211; into custom objects/classes or into collections like dictionaries and arrays. For this exercise I decided to create Ioke dictionaries and arrays and I want the result to work like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;">json<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #ff0000;">&quot;string&quot;</span> : <span style="color: #ff0000;">&quot;string1&quot;</span>,
  <span style="color: #ff0000;">&quot;int&quot;</span> : <span style="color: #cc66cc;">1234</span>,
  <span style="color: #ff0000;">&quot;arr&quot;</span> : <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;item1&quot;</span>, <span style="color: #ff0000;">&quot;item2&quot;</span><span style="color: #66cc66;">&#93;</span>,
  <span style="color: #ff0000;">&quot;dict&quot;</span> : <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;key1&quot;</span>:<span style="color: #ff0000;">&quot;value1&quot;</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">println</span>  <span style="color: #808080; font-style: italic;">;; =&gt; {dict={key1=value1}, arr=[item1, item2], int=1234, string=string1}</span>
&nbsp;
json<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;string&quot;</span>,
  <span style="color: #cc66cc;">1234</span>,
  <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;item1&quot;</span>, <span style="color: #ff0000;">&quot;item2&quot;</span><span style="color: #66cc66;">&#93;</span>,
  <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;key1&quot;</span>: <span style="color: #ff0000;">&quot;val1&quot;</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">println</span> <span style="color: #808080; font-style: italic;">;; =&gt; [string, 1234, [item1, item2], {key1=val1}]</span></pre></div></div>

<p>Now, looking at JSON, it&#8217;s suspiciously similar to Ioke &#8211; [] is used for arrays, {} is used for &#8220;dictionaries&#8221;, comma separates entries, &#8221; quotes strings, etc. The main problem is the colon &#8220;:&#8221; used for separating keys and values in a dictionary. As Ioke is a dynamic language we can redefine how messages are handled. Instead of using colon to define symbols, we can redefine it to instead create pairs suitable for a dict:</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;"><span style="color: #000066;">Text</span> <span style="color: #000000; font-weight: bold;">cell</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #66cc66;">&#41;</span> = <span style="color: #b1b100;">macro</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">call</span> resendToMethod<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;=&gt;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>&#8220;:&#8221; is originally defined on DefaultBehavior Literals, but in the JSON the &#8220;:&#8221; message is always sent to Text, so it&#8217;s enough to redefine it there.</p>
<p>This single redefinition allows us to parse JSON directly with the Ioke reader &#8211; very nice.</p>
<p>But&#8230; Redefining &#8220;:&#8221; for all Text objects is not really good (especially not when Ola adds concurrency constructs!). Another alternative would be to redefine how the text objects are created and create a new &#8220;:&#8221; cell just for our JSON text objects &#8211; but I never got this to work, as the internal:createText message works with a raw Java string, which I couldn&#8217;t work with in a macro/method&#8230;</p>
<p><strong>Update:</strong> With <a href="http://github.com/olabini/ioke/commit/8af3954df7961b3f594c73db5059310469e45df5">Ola&#8217;s recent commit</a>, the previously described workaround can now be simplified to the following code.</p>
<p>Now the above redefinition of the &#8220;:&#8221; message can be used, but is visible only in the scope of a <code>let</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="ioke" style="font-family:monospace;">json = <span style="color: #b1b100;">macro</span><span style="color: #66cc66;">&#40;</span>let<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">Text</span> <span style="color: #000000; font-weight: bold;">cell</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #000066;">DefaultBehavior</span> <span style="color: #000000; font-weight: bold;">cell</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;=&gt;&quot;</span><span style="color: #66cc66;">&#41;</span>,
    <span style="color: #000000; font-weight: bold;">call</span> argAt<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;; Used as:</span>
&nbsp;
json<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #ff0000;">&quot;string&quot;</span> : <span style="color: #ff0000;">&quot;string1&quot;</span>,
  <span style="color: #ff0000;">&quot;int&quot;</span> : <span style="color: #cc66cc;">1234</span>,
  <span style="color: #ff0000;">&quot;arr&quot;</span> : <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;item1&quot;</span>, <span style="color: #ff0000;">&quot;item2&quot;</span><span style="color: #66cc66;">&#93;</span>,
  <span style="color: #ff0000;">&quot;dict&quot;</span> : <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;key1&quot;</span>:<span style="color: #ff0000;">&quot;value1&quot;</span><span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">println</span>
&nbsp;
json<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;string&quot;</span>,
  <span style="color: #cc66cc;">1234</span>,
  <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;item1&quot;</span>, <span style="color: #ff0000;">&quot;item2&quot;</span><span style="color: #66cc66;">&#93;</span>,
  <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;key1&quot;</span>: <span style="color: #ff0000;">&quot;val1&quot;</span><span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">println</span></pre></div></div>

<p>As can be seen, the Ioke macro functionality gives us nice control over how messages are handled, and the environment can be changed before the arguments are evaluated. I&#8217;m looking forward to the day when we have full Java interop and can use these powerful constructs to control Java code!</p>
<p>Source code to the above example is committed to my Ioke fork at: <a href="git://github.com/melwin/ioke.git">git://github.com/melwin/ioke.git</a></p>
<p>/M</p>
<p>PS: The thing that confuses me the most: how the heck are you supposed to pronounce Ioke?</p>
<p><strong>Update:</strong> Sam Aaron shared the fact that Ola pronounces it eye-oh-key in the following interview: <a href="http://www.akitaonrails.com/2008/11/22/rails-podcast-brasil-qcon-special-ola-bini-jruby-ioke">http://www.akitaonrails.com/2008/11/22/rails-podcast-brasil-qcon-special-ola-bini-jruby-ioke</a></p>
]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2009/01/simple-json-parser-in-ioke/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Caching Filter Queries with Coherence</title>
		<link>http://martin.elwin.com/blog/2008/09/caching-filter-queries-with-coherence/</link>
		<comments>http://martin.elwin.com/blog/2008/09/caching-filter-queries-with-coherence/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 20:56:59 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[coherence]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=28</guid>
		<description><![CDATA[A pretty nice thing that I recently tried with a customer was storing a query result in a query cache.
For instance, consider the following method:

public Collection getByFilter1&#40;String cacheName, Filter f&#41; &#123;
    NamedCache c = CacheFactory.getCache&#40;cacheName&#41;;
    return c.entrySet&#40;f&#41;;
&#125;

A query is executed across all nodes containing cache data in a cluster. [...]]]></description>
			<content:encoded><![CDATA[<p>A pretty nice thing that I recently tried with a customer was storing a query result in a query cache.</p>
<p>For instance, consider the following method:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Collection</span> getByFilter1<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> cacheName, Filter f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    NamedCache c <span style="color: #339933;">=</span> CacheFactory.<span style="color: #006633;">getCache</span><span style="color: #009900;">&#40;</span>cacheName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> c.<span style="color: #006633;">entrySet</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A query is executed across all nodes containing cache data in a cluster. The filter acts on the <em>values</em> in the cache, not the keys. And as all values are usually not available locally on every node the query needs to execute on the separate nodes.</p>
<p>The query above is correct, but not very efficient. In the above case we query and retrieve the data as well from the separate nodes. A more efficient way would be to only get the keys for the matching values from the nodes and then retrieve the values from the local near cache:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Collection</span> getByFilter2<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> cacheName, Filter f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    NamedCache c <span style="color: #339933;">=</span> CacheFactory.<span style="color: #006633;">getCache</span><span style="color: #009900;">&#40;</span>cacheName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">Set</span> keys <span style="color: #339933;">=</span> c.<span style="color: #006633;">keySet</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> c.<span style="color: #006633;">getAll</span><span style="color: #009900;">&#40;</span>keys<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>However, in this case we still perform the query every time.</p>
<p>Now &#8211; the clever part. Not so much on my side, but the Coherence engineers have thought things through and made the Filter implementations have good hashCode and equals implementations. This together with the fact that they are serializable makes them possible to use as keys in a cache! Sweet! Without changing our method&#8217;s interface we can add a query cache so that each query only is performed once.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Collection</span> getByFilter3<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> cacheName, Filter f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    NamedCache c <span style="color: #339933;">=</span> CacheFactory.<span style="color: #006633;">getCache</span><span style="color: #009900;">&#40;</span>cacheName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    NamedCache queryC <span style="color: #339933;">=</span> CacheFactory.<span style="color: #006633;">getCache</span><span style="color: #009900;">&#40;</span>cacheName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.querycache&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">Set</span> keys <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Set</span><span style="color: #009900;">&#41;</span>queryC.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>keys <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        keys <span style="color: #339933;">=</span> c.<span style="color: #006633;">keySet</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        queryC.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>f, keys<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">return</span> c.<span style="color: #006633;">getAll</span><span style="color: #009900;">&#40;</span>keys<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Note that we only save the keys in the query cache. This to avoid having several caches with the same data. When near caching is used, getting the data for the keys can still be a local only operation. Compared to getting the data from the separate nodes it&#8217;s several orders of magnitude faster &#8211; depending on the usage patterns.</p>
<p>Of course if queries are different every time, the query cache will not help much. But in most high load applications the same data tends to be needed several times.</p>
<p>Additionally, the properties queried on should in most cases be indexed. This is important to avoid too much overhead when searching for an entry in a cache.</p>
<p>One thing to think about when adding query caches is: how is data updated?</p>
<p>As part of updating the value caches the query caches should preferably be emptied of the outdated cached queries. This could be done programmatically &#8220;manually&#8221; when the data is updated, or by hooking in code to clean the entries from the query cache using the map listener mechanism. The relevant code could do a query using the ContainsFilter.</p>
<p>To summarize: a little code can go a long way to improve performance without affecting the interface used by an application. Good when query heavy applications are adapted to use a distributed cache like Coherence.</p>
<p>/M</p>
]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2008/09/caching-filter-queries-with-coherence/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Scala Syntax Highlighting for WP</title>
		<link>http://martin.elwin.com/blog/2008/06/scala-syntax-highlighting-for-wp/</link>
		<comments>http://martin.elwin.com/blog/2008/06/scala-syntax-highlighting-for-wp/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 07:56:52 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[geshi]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://martin.elwin.com/blog/?p=27</guid>
		<description><![CDATA[Writing the previous post I realized that the Wordpress plugin for syntax highligting I was using (Highlight Source Pro) didn&#8217;t support Scala.
Instead I tried the WP-Syntax plugin, but this didn&#8217;t support Symbol literals:

val sym = 'foobar
println(&#34;Symbol is: &#34; + sym)
val other = 'barfoo

This seems to be because of single quote being interpreted as a quotation [...]]]></description>
			<content:encoded><![CDATA[<p>Writing the previous post I realized that the Wordpress plugin for syntax highligting I was using (Highlight Source Pro) didn&#8217;t support Scala.</p>
<p>Instead I tried the WP-Syntax plugin, but this didn&#8217;t support Symbol literals:</p>

<div class="wp_syntax"><div class="code"><pre class="scala-old" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> sym <span style="color: #000080;">=</span> <span style="color: #6666FF;">'foobar
println(&quot;Symbol is: &quot; + sym)
val other = '</span>barfoo</pre></div></div>

<p>This seems to be because of single quote being interpreted as a quotation character. A fix seems to be removing the single quote from the Geshi language definition file <code>scala.php</code> in the <code>wp-syntax/geshi/geshi</code> directory. While there one can also specify a regex for symbols and give them their own color:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">val</span> sym <span style="color: #000080;">=</span> <span style="color: #6666FF;">'foobar
println(&quot;Symbol is: &quot; + sym)
val other = '</span>barfoo</pre></div></div>

<p>Also check out the <a href="https://lampsvn.epfl.ch/trac/scala/browser/scala-tool-support/trunk/src/geshi/scala.php"><code>scala.php</code> in the LAMP repository</a> &#8211; it seems to add some additional keywords and other colors. I used this and made the changes described above.</p>
<p>Full new <code>scala.php</code> for Geshi after the break.</p>
<p><span id="more-27"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*************************************************************************************
 * scala.php
 * --------
 * Author: Geoffrey Washburn (washburn@acm.ogr)
 * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/)
 * Release Version: ???
 * Date Started: 2008/01/03
 *
 * Scala language file for GeSHi.
 *
 * CHANGES
 * -------
 * 2007/01/03
 *   -  Created by copying the Java highlighter
 *
 * TODO
 * -------------------------
 * * Finish
 *
 *************************************************************************************
 *
 *     This file is part of GeSHi.
 *
 *   GeSHi is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   GeSHi is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with GeSHi; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 ************************************************************************************/</span>
&nbsp;
<span style="color: #000088;">$language_data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'LANG_NAME'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Scala'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'COMMENT_SINGLE'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'//'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>   <span style="color: #666666; font-style: italic;">/* import statements are not comments! */</span>
        <span style="color: #0000ff;">'COMMENT_MULTI'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/*'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'*/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'CASE_KEYWORDS'</span> <span style="color: #339933;">=&gt;</span> GESHI_CAPS_NO_CHANGE<span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'QUOTEMARKS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot;&quot;&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'ESCAPE_CHAR'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'\\'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'KEYWORDS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                1 <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #666666; font-style: italic;">/* Scala keywords, part 1: control flow */</span>
                        <span style="color: #0000ff;">'case'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'default'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'do'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'else'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'for'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'if'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'match'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'while'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                2 <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #666666; font-style: italic;">/* Scala keywords, part 2 */</span>
                        <span style="color: #0000ff;">'return'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'throw'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'try'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'catch'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'finally'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'abstract'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'class'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'def'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'extends'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'final'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'forSome'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'implicit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'import'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'lazy'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'new'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'object'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'override'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'package'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'private'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'protected'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'requires'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sealed'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'super'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'this'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'trait'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'type'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'val'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'var'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'with'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yield'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                3 <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #666666; font-style: italic;">/* Scala keywords, part 3: standard value types */</span>
                        <span style="color: #0000ff;">'unit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Unit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'boolean'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Boolean'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'int'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Int'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Any'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'AnyVal'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Nothing'</span><span style="color: #339933;">,</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                4 <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #666666; font-style: italic;">/* other reserved words in Scala: literals */</span>
                        <span style="color: #666666; font-style: italic;">/* should be styled to look similar to numbers and Strings */</span>
                        <span style="color: #0000ff;">'false'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'null'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'true'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                5 <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #666666; font-style: italic;">/* Scala reference types */</span>
                        <span style="color: #0000ff;">'AnyRef'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Null'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'List'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'String'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Integer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Option'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Array'</span>
                        <span style="color: #009900;">&#41;</span>
&nbsp;
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'SYMBOLS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">':'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'*'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">';'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'?'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'='</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'=&gt;'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'&lt;-'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;%'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&gt;:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'#'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'@'</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'CASE_SENSITIVE'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                GESHI_COMMENTS <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                <span style="color: #666666; font-style: italic;">/* all Scala keywords are case sensitive */</span>
                1 <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> 2 <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> 3 <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> 4 <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> 5 <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'STYLES'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'KEYWORDS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #b1b100;'</span><span style="color: #339933;">,</span>
                        <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #000000; font-weight: bold;'</span><span style="color: #339933;">,</span>
                        <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #993333;'</span><span style="color: #339933;">,</span>
                        <span style="color: #cc66cc;">4</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #b13366;'</span><span style="color: #339933;">,</span>
                        <span style="color: #cc66cc;">5</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #aaaadd;'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'SYMBOLS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #FFAA00;'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'COMMENTS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #808080; font-style: italic;'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'MULTI'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #808080; font-style: italic;'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'ESCAPE_CHAR'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #000099; font-weight: bold;'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'BRACKETS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #66cc66;'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'STRINGS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #ff0000;'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'NUMBERS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #cc66cc;'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'METHODS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #006600;'</span><span style="color: #339933;">,</span>
                        <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #006600;'</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'SCRIPT'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'REGEXPS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #008000;'</span>
                        <span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'URLS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                <span style="color: #cc66cc;">4</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'OOLANG'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'OBJECT_SPLITTERS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'.'</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'REGEXPS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
               <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;'[a-zA-Z_][a-zA-Z0-9_]*&quot;</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'STRICT_MODE_APPLIES'</span> <span style="color: #339933;">=&gt;</span> GESHI_NEVER<span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'SCRIPT_DELIMITERS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'HIGHLIGHT_STRICT_BLOCK'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://martin.elwin.com/blog/2008/06/scala-syntax-highlighting-for-wp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
