<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>SRFI: wisp: simpler indentation-sensitive scheme</title>
<!-- 2014-12-23 Di 17:17 -->
<meta  http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta  name="generator" content="Org-mode" />
<meta  name="author" content="Arne Babenhauserheide" />
<style type="text/css">
 <!--/*--><![CDATA[/*><!--*/
  .title  { text-align: center; }
  .todo   { font-family: monospace; color: red; }
  .done   { color: green; }
  .tag    { background-color: #eee; font-family: monospace;
            padding: 2px; font-size: 80%; font-weight: normal; }
  .timestamp { color: #bebebe; }
  .timestamp-kwd { color: #5f9ea0; }
  .right  { margin-left: auto; margin-right: 0px;  text-align: right; }
  .left   { margin-left: 0px;  margin-right: auto; text-align: left; }
  .center { margin-left: auto; margin-right: auto; text-align: center; }
  .underline { text-decoration: underline; }
  #postamble p, #preamble p { font-size: 90%; margin: .2em; }
  p.verse { margin-left: 3%; }
  pre {
    border: 1px solid #ccc;
    box-shadow: 3px 3px 3px #eee;
    padding: 8pt;
    font-family: monospace;
    overflow: auto;
    margin: 1.2em;
  }
  pre.src {
    position: relative;
    overflow: visible;
    padding-top: 1.2em;
  }
  pre.src:before {
    display: none;
    position: absolute;
    background-color: white;
    top: -10px;
    right: 10px;
    padding: 3px;
    border: 1px solid black;
  }
  pre.src:hover:before { display: inline;}
  pre.src-sh:before    { content: 'sh'; }
  pre.src-bash:before  { content: 'sh'; }
  pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
  pre.src-R:before     { content: 'R'; }
  pre.src-perl:before  { content: 'Perl'; }
  pre.src-java:before  { content: 'Java'; }
  pre.src-sql:before   { content: 'SQL'; }

  table { border-collapse:collapse; }
  caption.t-above { caption-side: top; }
  caption.t-bottom { caption-side: bottom; }
  td, th { vertical-align:top;  }
  th.right  { text-align: center;  }
  th.left   { text-align: center;   }
  th.center { text-align: center; }
  td.right  { text-align: right;  }
  td.left   { text-align: left;   }
  td.center { text-align: center; }
  dt { font-weight: bold; }
  .footpara:nth-child(2) { display: inline; }
  .footpara { display: block; }
  .footdef  { margin-bottom: 1em; }
  .figure { padding: 1em; }
  .figure p { text-align: center; }
  .inlinetask {
    padding: 10px;
    border: 2px solid gray;
    margin: 10px;
    background: #ffffcc;
  }
  #org-div-home-and-up
   { text-align: right; font-size: 70%; white-space: nowrap; }
  textarea { overflow-x: auto; }
  .linenr { font-size: smaller }
  .code-highlighted { background-color: #ffff00; }
  .org-info-js_info-navigation { border-style: none; }
  #org-info-js_console-label
    { font-size: 10px; font-weight: bold; white-space: nowrap; }
  .org-info-js_search-highlight
    { background-color: #ffff00; color: #000000; font-weight: bold; }
  /*]]>*/-->
</style>
<script type="text/javascript">
/*
@licstart  The following is the entire license notice for the
JavaScript code in this tag.

Copyright (C) 2012-2013 Free Software Foundation, Inc.

The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version.  The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.


@licend  The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
 function CodeHighlightOn(elem, id)
 {
   var target = document.getElementById(id);
   if(null != target) {
     elem.cacheClassElem = elem.className;
     elem.cacheClassTarget = target.className;
     target.className = "code-highlighted";
     elem.className   = "code-highlighted";
   }
 }
 function CodeHighlightOff(elem, id)
 {
   var target = document.getElementById(id);
   if(elem.cacheClassElem)
     elem.className = elem.cacheClassElem;
   if(elem.cacheClassTarget)
     target.className = elem.cacheClassTarget;
 }
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<h1 class="title">SRFI: wisp: simpler indentation-sensitive scheme</h1>
<div class="abstract">
<p>
This SRFI describes a simple syntax which allows making scheme easier to read for newcomers while keeping the simplicity, generality and elegance of s-expressions. Similar to SRFI-110, SRFI-49 and Python it uses indentation to group expressions. Like SRFI-110 wisp is general and homoiconic. 
</p>

<p>
Different from its precedessors, wisp only uses the absolute minimum of additional syntax-elements which are required for writing and exchanging arbitrary code-structures. As syntax elements it only uses a colon surrounded by whitespace, the period followed by whitespace as first code-character on the line and optional underscores followed by whitespace at the beginning of the line.
</p>

<p>
It resolves a limitation of SRFI-110 and SRFI-49, both of which force the programmer to use a single argument per line if the arguments to a function need to be continued after a function-call.
</p>

<p>
Wisp expressions can include any s-expressions and as such provide backwards compatibility.
</p>

<table><tr><th>wisp</th><th>s-exp</th></tr><tr><td>
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">hello</span> who
<span style="color: #0000ff;">  format</span> <span style="color: #008b8b;">#t</span> <span style="color: #C33;">"~A ~A!\n"</span>
<span style="color: #a020f0;">          . </span><span style="color: #C33;">"Hello"</span> who
<span style="color: #0000ff;">hello</span>       <span style="color: #C33;">"Wisp"</span>
</pre>
</div>
</td><td>
<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">hello</span> who)
  (format #t <span style="color: #C33;">"~A ~A!\n"</span>
             <span style="color: #C33;">"Hello"</span> who))
(hello       <span style="color: #C33;">"S-exp"</span>)
</pre>
</div>
</td></tr></table>

</div>

<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1. Authors</a>
<ul>
<li><a href="#sec-1-1">1.1. Acknowledgments</a></li>
</ul>
</li>
<li><a href="#sec-2">2. Related SRFIs</a></li>
<li><a href="#sec-3">3. Rationale</a>
<ul>
<li><a href="#sec-3-1">3.1. Wisp example</a></li>
<li><a href="#sec-3-2">3.2. Advantages of Wisp</a></li>
<li><a href="#sec-3-3">3.3. Disadvantages of Wisp</a></li>
</ul>
</li>
<li><a href="#sec-4">4. Specification</a>
<ul>
<li><a href="#sec-4-1">4.1. Overview</a></li>
<li><a href="#sec-4-2">4.2. More detailed: Wisp syntax rules</a></li>
<li><a href="#sec-4-3">4.3. Clarifications</a></li>
</ul>
</li>
<li><a href="#sec-5">5. Syntax justification</a>
<ul>
<li><a href="#sec-5-1">5.1. . (the dot)</a></li>
<li><a href="#sec-5-2">5.2. : (the colon)</a></li>
<li><a href="#sec-5-3">5.3. _ (the underscore)</a></li>
</ul>
</li>
<li><a href="#sec-6">6. Implementation</a>
<ul>
<li><a href="#sec-6-1">6.1. The generic wisp processor (code)</a></li>
<li><a href="#sec-6-2">6.2. Test Suite</a></li>
</ul>
</li>
<li><a href="#sec-7">7. Copyright</a></li>
</ul>
</div>
</div>

<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Authors</h2>
<div class="outline-text-2" id="text-1">
<ul class="org-ul">
<li>Arne Babenhauserheide
</li>
</ul>
</div>

<div id="outline-container-sec-1-1" class="outline-3">
<h3 id="sec-1-1"><span class="section-number-3">1.1</span> Acknowledgments</h3>
<div class="outline-text-3" id="text-1-1">
<ul class="org-ul">
<li>Thanks for many constructive discussions goes to Alan Manuel K. Gloria and David A. Wheeler.
</li>
<li>Also thanks to Mark Weaver for his help with the wisp parser and the guile integration - including a 20x speedup.
</li>
</ul>
</div>
</div>
</div>

<div id="outline-container-sec-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Related SRFIs</h2>
<div class="outline-text-2" id="text-2">
<ul class="org-ul">
<li>SRFI-49 (Indentation-sensitive syntax): superceded by this SRFI, 
</li>
<li>SRFI-110 (Sweet-expressions (t-expressions)): alternative to this SRFI,
</li>
<li>SRFI-105 (neoteric expressions and curly infix): supported in this SRFI by treating curly braces like brackets and parentheses. Curly infix is required by the implementation and the testsuite.
</li>
<li>SRFI-30 (Nested Multi-line comments): complex interaction. Should be avoided at the beginning of lines, because it can make the indentation hard to distinguish for humans. SRFI-110 includes them, so there might be value in adding them. The wisp reference implementation does not treat them specially, though, which might create arbitrary complications.
</li>
</ul>
</div>
</div>

<div id="outline-container-sec-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Rationale</h2>
<div class="outline-text-2" id="text-3">
<p>
A big strength of Scheme and other lisp-like languages is their minimalistic syntax. By using only the most common characters like the period, the comma, the quote and quasiquote, the hash, the semicolon and the parens for the syntax (<code>.,"'`#;()</code>), they are very close to natural language<sup><a id="fnr.1" name="fnr.1" class="footref" href="#fn.1">1</a></sup>. Along with the minimal list-structure of the code, this gives these languages a timeless elegance.
</p>

<p>
But as SRFI-110 explains very thoroughly (which we need not repeat here), the parentheses at the beginning of lines hurt readability and scare away newcomers. Additionally using indentation to mark the structure of the code follows naturally from the observation that most programmers use indentation, with many programmers letting their editor indent code automatically to fit the structure. Indentation is an important way how programmers understand code and using it directly to define the structure avoids errors due to mismatches between indentation and actual meaning.
</p>

<p>
As a solution to this, SRFI-49 and SRFI-110 provide a way to write whitespace sensitive scheme, but both have their share of issues.
</p>

<p>
As noted in SRFI-110, there are a number of implementation-problems in SRFI-49, as well as specification shortcomings like choosing the name “group” for the construct which is necessary to represent double parentheses. In addition to the problems named in SRFI-110, SRFI-49 is not able to continue the arguments to a function on one line, if a prior argument was a function call. The following example shows the difference between wisp and SRFI-49 for a very simple code snippet:
</p>

<table><tr><th>wisp</th><th>SRFI-49</th></tr><tr><td>
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">*</span> <span style="color: #008b8b;">5</span>
<span style="color: #0000ff;">  +</span> <span style="color: #008b8b;">4</span> <span style="color: #008b8b;">3</span>
<span style="color: #a020f0;">  . </span><span style="color: #008b8b;">2</span> <span style="color: #008b8b;">1</span>
</pre>
</div>
</td><td>
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">*</span> <span style="color: #008b8b;">5</span>
<span style="color: #0000ff;">  +</span> <span style="color: #008b8b;">4</span> <span style="color: #008b8b;">3</span>
<span style="color: #0000ff;">  2</span>
<span style="color: #0000ff;">  1</span>
</pre>
</div>
</td></tr></table>

<p>
SRFI-110 improves a lot over the implementation of SRFI-49. It resolves the group-naming and reduces the need to continue the argument-list by introducing 3 different grouping syntaxes (<code>$</code>, <code>\\</code> and <code><* *></code>). These additional syntax-elements however hurt readability for newcomers (obviously the authors of SRFI-110 disagree with this assertion. Their view is discussed in SRFI-110 in the section about wisp). The additional syntax elements lead to structures like the following (taken from examples from the readable project):
</p>
<div class="org-src-container">

<pre class="src src-scheme">myfunction 
  x: \\ original-x
  y: \\ calculate-y original-y
</pre>
</div>

<div class="org-src-container">

<pre class="src src-scheme">a b $ c d e $ f g
</pre>
</div>

<div class="org-src-container">

<pre class="src src-scheme">let <* x getx() \\ y gety() *>
! {{x * x} + {y * y}}
</pre>
</div>

<p>
This is not only hard to read, but also makes it harder to work with the code, because the programmer has to learn these additional syntax elements and keep them in mind before being able to understand the code.
</p>

<p>
Like SRFI-49 SRFI-110 also cannot continue the argument-list without resorting to single-element lines, though it reduces this problem by the above grouping syntaxes and advertising the use of neoteric expressions from SRFI-105.
</p>
</div>

<div id="outline-container-sec-3-1" class="outline-3">
<h3 id="sec-3-1"><span class="section-number-3">3.1</span> Wisp example</h3>
<div class="outline-text-3" id="text-3-1">
<p>
Since an example speaks more than a hundred explanations, the following shows wisp exploiting all its features - including curly-infix from SRFI-105:
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> n
<span style="color: #0000ff;">__</span>  <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">zero?</span> n
<span style="color: #0000ff;">____</span><span style="color: #a020f0;">   . </span><span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">____   *</span> n<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> {n - 1}

<span style="color: #0000ff;">display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> <span style="color: #008b8b;">5</span> 
<span style="color: #0000ff;">newline</span>
</pre>
</div>
</div>
</div>

<div id="outline-container-sec-3-2" class="outline-3">
<h3 id="sec-3-2"><span class="section-number-3">3.2</span> Advantages of Wisp</h3>
<div class="outline-text-3" id="text-3-2">
<p>
Wisp draws on the strength of SRFI-110 but avoids its complexities. It was conceived and improved in the discussions within the readable-project which preceded SRFI-110 and there is a comparison between readable in wisp in SRFI-110.
</p>

<p>
Like SRFI-110, wisp is general and homoiconic and interacts nicely with SRFI-105 (neoteric expressions and curly infix). Like SRFI-110, the expressions are the same in the REPL and in code-files. Like SRFI-110, wisp has been used for implementing multiple smaller programs, though the biggest program in wisp is still its implementations (written in wisp and bootstrapped via a simpler wisp preprocessor).
</p>

<p>
But unlike SRFI-110, wisp only uses the minimum of additional syntax-elements which are necessary to support arbitrary code-structures with indentation-sensitive code which is intended to be shared over the internet. To realize these syntax-elements, it generalizes existing syntax and draws on the most common non-letter non-math characters in prose. This allows keeping the actual representation of the code elegant and inviting to newcomers.
</p>

<p>
Wisp expressions are not as sweet as <a href="http://readable.sf.net">readable</a>, but they KISS.
</p>
</div>
</div>

<div id="outline-container-sec-3-3" class="outline-3">
<h3 id="sec-3-3"><span class="section-number-3">3.3</span> Disadvantages of Wisp</h3>
<div class="outline-text-3" id="text-3-3">
<p>
Using the colon as syntax element keeps the code very close to written prose, but it can interfere with type definitions as for example used in Typed Racket<sup><a id="fnr.2" name="fnr.2" class="footref" href="#fn.2">2</a></sup>. This can be mitigated in let- and lambda-forms by using the parenthesized form. When doing so, wisp avoids the double-paren for type-declarations and as such makes them easier to catch by eye. For function definitions (the only <code>define</code> call where type declarations are needed in typed-racket<sup><a id="fnr.3" name="fnr.3" class="footref" href="#fn.3">3</a></sup>), a <code>declare</code> macro directly before the <code>define</code> should work well.
</p>

<p>
Using the period to continue the argument list is unusual compared to other languages and as such can lead to errors when trying to return a variable from a procedure and forgetting the period.
</p>
</div>
</div>
</div>

<div id="outline-container-sec-4" class="outline-2">
<h2 id="sec-4"><span class="section-number-2">4</span> Specification</h2>
<div class="outline-text-2" id="text-4">
<p>
The specification is separated into four parts: A general overview of the syntax, a more detailed description, justifications for each added syntax element and clarifications for technical details.
</p>
</div>

<div id="outline-container-sec-4-1" class="outline-3">
<h3 id="sec-4-1"><span class="section-number-3">4.1</span> Overview</h3>
<div class="outline-text-3" id="text-4-1">
<p>
The basics of wisp syntax can be defined in 4 rules, each of which emerges directly from a requirement:
</p>
</div>

<div id="outline-container-sec-4-1-1" class="outline-4">
<h4 id="sec-4-1-1"><span class="section-number-4">4.1.1</span> Wisp syntax 1/4: function calls</h4>
<div class="outline-text-4" id="text-4-1-1">
<p>
Indentation:
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">display</span> 
<span style="color: #0000ff;">  +</span> <span style="color: #008b8b;">3</span> <span style="color: #008b8b;">4</span> <span style="color: #008b8b;">5</span>
<span style="color: #0000ff;">newline</span>
</pre>
</div>

<p>
becomes
</p>

<div class="org-src-container">

<pre class="src src-scheme">(display 
  (+ 3 4 5))
(newline)
</pre>
</div>

<p>
<i>requirement: call functions without parenthesis.</i>
</p>
</div>
</div>

<div id="outline-container-sec-4-1-2" class="outline-4">
<h4 id="sec-4-1-2"><span class="section-number-4">4.1.2</span> Wisp syntax 2/4: Continue Argument list</h4>
<div class="outline-text-4" id="text-4-1-2">
<p>
The period:
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">+</span> <span style="color: #008b8b;">5</span>
<span style="color: #0000ff;">  *</span> <span style="color: #008b8b;">4</span> <span style="color: #008b8b;">3</span>
<span style="color: #a020f0;">  . </span><span style="color: #008b8b;">2</span> <span style="color: #008b8b;">1</span>
</pre>
</div>

<p>
becomes
</p>

<div class="org-src-container">

<pre class="src src-scheme">(+ 5
  (* 4 3)
  2 1)
</pre>
</div>

<p>
This also works with just one argument after the period. To start a line without a function call, you have to prefix it with a period followed by whitespace.<sup><a id="fnr.4" name="fnr.4" class="footref" href="#fn.4">4</a></sup>
</p>

<p>
<i>requirement: continue the argument list of a function after an intermediate call to another function.</i>
</p>
</div>
</div>

<div id="outline-container-sec-4-1-3" class="outline-4">
<h4 id="sec-4-1-3"><span class="section-number-4">4.1.3</span> Wisp syntax 3/4: Double Parens</h4>
<div class="outline-text-4" id="text-4-1-3">
<p>
The colon:<sup><a id="fnr.5" name="fnr.5" class="footref" href="#fn.5">5</a></sup>
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">let</span> 
<span style="color: #a020f0;">  : </span><span style="color: #0000ff;">x</span> <span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">    y</span> <span style="color: #008b8b;">2</span>
<span style="color: #0000ff;">    z</span> <span style="color: #008b8b;">3</span>
<span style="color: #0000ff;">  body</span>
</pre>
</div>

<p>
becomes
</p>

<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">let</span>
  ((x 1)
   (y 2)
   (z 3))
  (body))
</pre>
</div>

<p>
<i>requirement: represent code with two adjadent blocks in double-parentheses.</i>
</p>
</div>
</div>

<div id="outline-container-sec-4-1-4" class="outline-4">
<h4 id="sec-4-1-4"><span class="section-number-4">4.1.4</span> Wisp syntax 4/4: Resilient Indentation</h4>
<div class="outline-text-4" id="text-4-1-4">
<p>
The underscore (optional):
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">let</span> 
<span style="color: #a020f0;">_ : </span><span style="color: #0000ff;">x</span> <span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">__  y</span> <span style="color: #008b8b;">2</span>
<span style="color: #0000ff;">__  z</span> <span style="color: #008b8b;">3</span>
<span style="color: #0000ff;">_ body</span>
</pre>
</div>

<p>
becomes
</p>

<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">let</span>
  ((x 1)
   (y 2)
   (z 3))
  (body))
</pre>
</div>

<p>
<i>requirement: share code in environments which do not preserve whitespace.</i>
</p>
</div>
</div>

<div id="outline-container-sec-4-1-5" class="outline-4">
<h4 id="sec-4-1-5"><span class="section-number-4">4.1.5</span> Summary</h4>
<div class="outline-text-4" id="text-4-1-5">
<p>
The syntax shown here is the minimal syntax required for the goal of wisp: indentation-based, general lisp with a simple preprocessor, and code which can be shared easily on the internet:
</p>

<ul class="org-ul">
<li><code>.</code> to continue the argument list
</li>
<li><code>:</code> for double parens
</li>
<li><code>_</code> to survive HTML
</li>
</ul>
</div>
</div>
</div>

<div id="outline-container-sec-4-2" class="outline-3">
<h3 id="sec-4-2"><span class="section-number-3">4.2</span> More detailed: Wisp syntax rules</h3>
<div class="outline-text-3" id="text-4-2">
</div><div id="outline-container-sec-4-2-1" class="outline-4">
<h4 id="sec-4-2-1"><span class="section-number-4">4.2.1</span> Unindented line</h4>
<div class="outline-text-4" id="text-4-2-1">
<p>
<b>A line without indentation is a function call</b>, just as if it would start with a parenthesis.
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">display</span> <span style="color: #C33;">"Hello World!"</span>      <span style="color: #898887;">;      </span><span style="color: #898887;">(display "Hello World!")</span>
</pre>
</div>
</div>
</div>

<div id="outline-container-sec-4-2-2" class="outline-4">
<h4 id="sec-4-2-2"><span class="section-number-4">4.2.2</span> Sibling line</h4>
<div class="outline-text-4" id="text-4-2-2">
<p>
<b>A line which is more indented than the previous line is a sibling to that line</b>: It opens a new parenthesis.
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">display</span>                              <span style="color: #898887;">;    </span><span style="color: #898887;">(display</span>
<span style="color: #0000ff;">  string-append</span> <span style="color: #C33;">"Hello "</span> <span style="color: #C33;">"World!"</span>    <span style="color: #898887;">;      </span><span style="color: #898887;">(string-append "Hello " "World!"))</span>
</pre>
</div>
</div>
</div>

<div id="outline-container-sec-4-2-3" class="outline-4">
<h4 id="sec-4-2-3"><span class="section-number-4">4.2.3</span> Closing line</h4>
<div class="outline-text-4" id="text-4-2-3">
<p>
<b>A line which is not more indented than previous line(s) closes the parentheses of all previous lines which have higher or equal indentation</b>. You should only reduce the indentation to indentation levels which were already used by parent lines, else the behaviour is undefined.
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">display</span>                              <span style="color: #898887;">;    </span><span style="color: #898887;">(display</span>
<span style="color: #0000ff;">  string-append</span> <span style="color: #C33;">"Hello "</span> <span style="color: #C33;">"World!"</span>    <span style="color: #898887;">;      </span><span style="color: #898887;">(string-append "Hello " "World!"))</span>
<span style="color: #0000ff;">display</span> <span style="color: #C33;">"Hello Again!"</span>               <span style="color: #898887;">;    </span><span style="color: #898887;">(display "Hello Again!")</span>
</pre>
</div>
</div>
</div>

<div id="outline-container-sec-4-2-4" class="outline-4">
<h4 id="sec-4-2-4"><span class="section-number-4">4.2.4</span> Prefixed line</h4>
<div class="outline-text-4" id="text-4-2-4">
<p>
<b>To add any of ' , ` #' #, #` or #@, to the first parenthesis on a line, just prefix the line with that symbol</b> followed by at least one space. Implementations are free to add more prefix symbols.
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">'</span> <span style="color: #C33;">"Hello World!"</span>      <span style="color: #898887;">;      </span><span style="color: #898887;">'("Hello World!")</span>
</pre>
</div>
</div>
</div>


<div id="outline-container-sec-4-2-5" class="outline-4">
<h4 id="sec-4-2-5"><span class="section-number-4">4.2.5</span> Continuing line</h4>
<div class="outline-text-4" id="text-4-2-5">
<p>
<b>A line whose first non-whitespace characters is a dot followed by a space (". ") does not open a new parenthesis: it is treated as simple continuation of the first less indented previous line</b>. In the first line this means that this line does not start with a parenthesis and does not end with a parenthesis, just as if you had directly written it in lisp without the leading ". ".
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">string-append</span> <span style="color: #C33;">"Hello"</span>        <span style="color: #898887;">;    </span><span style="color: #898887;">(string-append "Hello"</span>
<span style="color: #0000ff;">  string-append</span> <span style="color: #C33;">" "</span> <span style="color: #C33;">"World"</span>  <span style="color: #898887;">;      </span><span style="color: #898887;">(string-append " " "World")</span>
<span style="color: #a020f0;">  . </span><span style="color: #C33;">"!"</span>                      <span style="color: #898887;">;      </span><span style="color: #898887;">"!")</span>
</pre>
</div>
</div>
</div>


<div id="outline-container-sec-4-2-6" class="outline-4">
<h4 id="sec-4-2-6"><span class="section-number-4">4.2.6</span> Empty indentation level</h4>
<div class="outline-text-4" id="text-4-2-6">
<p>
<b>A line which contains only whitespace and a colon (":") defines an indentation level at the indentation of the colon</b>. It opens a parenthesis which gets closed by the next line which has less or equal indentation. If you need to use a colon by itself. you can escape it as "\:".
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">let</span>                       <span style="color: #898887;">;    </span><span style="color: #898887;">(let</span>
<span style="color: #a020f0;">  : </span>                      <span style="color: #898887;">;      </span><span style="color: #898887;">(</span>
<span style="color: #0000ff;">    msg</span> <span style="color: #C33;">"Hello World!"</span>    <span style="color: #898887;">;        </span><span style="color: #898887;">(msg "Hello World!"))</span>
<span style="color: #0000ff;">  display</span> msg             <span style="color: #898887;">;      </span><span style="color: #898887;">(display msg))</span>
</pre>
</div>
</div>
</div>


<div id="outline-container-sec-4-2-7" class="outline-4">
<h4 id="sec-4-2-7"><span class="section-number-4">4.2.7</span> Inline Colon</h4>
<div class="outline-text-4" id="text-4-2-7">
<p>
<b>A colon sourrounded by whitespace (" : ") starts a parenthesis which gets closed at the end of the line</b>.
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">hello</span> who                    <span style="color: #898887;">;    </span><span style="color: #898887;">(define (hello who)</span>
<span style="color: #0000ff;">  display</span>                             <span style="color: #898887;">;      </span><span style="color: #898887;">(display </span>
<span style="color: #0000ff;">    string-append</span> <span style="color: #C33;">"Hello "</span> who <span style="color: #C33;">"!"</span>    <span style="color: #898887;">;        </span><span style="color: #898887;">(string-append "Hello " who "!")))</span>
</pre>
</div>

<p>
If the colon starts a line which also contains other non-whitespace characters, it starts a parenthesis which gets closed at the end of the line <b>and</b> defines an indentation level at the position of the colon.
</p>

<p>
If the colon is the last non-whitespace character on a line, it represents an empty pair of parentheses:
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">let</span><span style="color: #a020f0;"> : </span>                <span style="color: #898887;">;    </span><span style="color: #898887;">(let ()</span>
<span style="color: #0000ff;">    display</span> <span style="color: #C33;">"Hello"</span>   <span style="color: #898887;">;         </span><span style="color: #898887;">(display "Hello"))</span>
</pre>
</div>
</div>
</div>

<div id="outline-container-sec-4-2-8" class="outline-4">
<h4 id="sec-4-2-8"><span class="section-number-4">4.2.8</span> Initial Underscores</h4>
<div class="outline-text-4" id="text-4-2-8">
<p>
<b>You can replace any number of consecutive initial spaces by underscores</b>, as long as at least one whitespace is left between the underscores and any following character. You can escape initial underscores by prefixing the first one with \ ("\___ a" → "(<span class="underline">_</span> a)"), if you have to use them as function names.
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">hello</span> who                    <span style="color: #898887;">;    </span><span style="color: #898887;">(define (hello who)</span>
<span style="color: #0000ff;">_ display</span>                             <span style="color: #898887;">;      </span><span style="color: #898887;">(display </span>
<span style="color: #0000ff;">___ string-append</span> <span style="color: #C33;">"Hello "</span> who <span style="color: #C33;">"!"</span>    <span style="color: #898887;">;        </span><span style="color: #898887;">(string-append "Hello " who "!")))</span>
</pre>
</div>
</div>
</div>

<div id="outline-container-sec-4-2-9" class="outline-4">
<h4 id="sec-4-2-9"><span class="section-number-4">4.2.9</span> Parens and Strings</h4>
<div class="outline-text-4" id="text-4-2-9">
<p>
<b>Linebreaks inside parentheses and strings are not considered linebreaks</b> for parsing indentation. To use parentheses at the beginning of a line without getting double parens, prefix the line with a period.
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">stringy</span> s 
<span style="color: #0000ff;">         string-append</span> s <span style="color: #C33;">" reversed and capitalized:</span>
<span style="color: #C33;"> "</span> <span style="color: #898887;">; </span><span style="color: #898887;">linebreaks in strings do not affect wisp parsing</span>
<span style="color: #a020f0;">           . </span>(<span style="color: #0000ff;">string-capitalize</span> <span style="color: #898887;">; </span><span style="color: #898887;">same for linebreaks in parentheses</span>
<span style="color: #0000ff;">             (string-reverse</span> s))
</pre>
</div>

<p>
Effectively code in parentheses and strings is interpreted directly as Scheme. This way you can simply copy a thunk of scheme into wisp. The following is valid wisp:
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span> foo (<span style="color: #0000ff;">+</span> <span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">  (*</span> <span style="color: #008b8b;">2</span> <span style="color: #008b8b;">3</span>)) <span style="color: #898887;">; </span><span style="color: #898887;">defines foo as 7</span>
</pre>
</div>
</div>
</div>
</div>

<div id="outline-container-sec-4-3" class="outline-3">
<h3 id="sec-4-3"><span class="section-number-3">4.3</span> Clarifications</h3>
<div class="outline-text-3" id="text-4-3">
<ul class="org-ul">
<li>Code-blocks end after 2 empty lines followed by a newline. Indented non-empty lines after 2 empty lines should be treated as error. A line is empty if it only contains whitespace. A line with a comment is never empty.
</li>

<li>Inside parentheses, wisp parsing is disabled. Consequently linebreaks inside parentheses are not considered linebreaks for wisp-parsing. For the parser everything which happens inside parentheses is treated as a black box.
</li>

<li>Square brackets and curly braces should be treated the same way as parentheses: They stop the indentation processing until they are closed.
</li>

<li>Likewise linebreaks inside strings are not considered linebreaks for wisp-parsing.
</li>

<li>A colon (:) at the beginning of a line adds an extra open parentheses that gets closed at end-of-line (rule 4.2.7) <b>and</b> defines an indentation level.
</li>

<li>using a quote to escape a symbol separated from it by whitespace is forbidden. This would make the meaning of quoted lines ambigous.
</li>

<li>Curly braces should be treated as curly-infix following SRFI-105. This makes most math look natural to newcomers.
</li>

<li>Neoteric expressions from SRFI-105 are not required because they create multiple ways to represent the same code. In wisp they add much less advantages than in sweet expressions from SRFI-110, because wisp can continue the arguments to a function after a function call (with the leading period) and the inline colon provides most of the benefits neoteric expressions give to sweet. However implementations providing wisp should give users the option to activate neoteric expressions as by SRFI-105 to allow experimentation and evolution (<a href="http://sourceforge.net/p/readable/mailman/message/33068104/">discussion</a>).
</li>

<li>It is possible to write code which is at the same time valid wisp and sweet. The readable mailinglist <a href="http://sourceforge.net/p/readable/mailman/message/33058992/">contains details</a>.
</li>
</ul>
</div>
</div>
</div>

<div id="outline-container-sec-5" class="outline-2">
<h2 id="sec-5"><span class="section-number-2">5</span> Syntax justification</h2>
<div class="outline-text-2" id="text-5">
<p>
<i>I do not like adding any unnecessary syntax element to lisp. So I want to show explicitely why the syntax elements are required.</i>
</p>

<small>
<p>
See also <a href="http://draketo.de/light/english/wisp-lisp-indentation-preprocessor#sec-4">http://draketo.de/light/english/wisp-lisp-indentation-preprocessor#sec-4</a>
</p>
</small>
</div>


<div id="outline-container-sec-5-1" class="outline-3">
<h3 id="sec-5-1"><span class="section-number-3">5.1</span> . (the dot)</h3>
<div class="outline-text-3" id="text-5-1">
<p>
To represent general code trees, we have to be able to represent continuation of the arguments of a function with an intermediate call to another (or the same) function.
</p>

<p>
The dot at the beginning of the line as marker of the continuation of a variable list is a generalization of using the dot as identity function - which is an implementation detail in many lisps.
</p>

<blockquote>
<p>
<code>(. a)</code> is just <code>a</code>
</p>
</blockquote>

<p>
So for the single variable case, this would not even need additional parsing: wisp could just parse <code>. a</code> to <code>(. a)</code> and produce the correct result in most lisps. But forcing programmers to always use separate lines for each parameter would be very inconvenient, so the definition of the dot at the beginning of the line is extended to mean “take every element in this line as parameter to the parent function”. 
</p>

<blockquote>
<p>
<code>(. a)</code> → <code>a</code> is generalized to <code>(. a b c)</code> → <code>a b c</code>.
</p>
</blockquote>

<p>
At its core, this dot-rule means that we mark variables in the code instead of function calls. We do so, because variables at the beginning of a line are much rarer in Scheme than in other programming languages.
</p>
</div>
</div>

<div id="outline-container-sec-5-2" class="outline-3">
<h3 id="sec-5-2"><span class="section-number-3">5.2</span> : (the colon)</h3>
<div class="outline-text-3" id="text-5-2">
<p>
For double parentheses and for some other cases we must have a way to mark indentation levels which do not contain code. Wisp uses the colon, because it is the most common non-alpha-numeric character in normal prose which is not already reserved as syntax by Scheme when it is surrounded by whitespace, and because it already gets used without sourrounding whitespace for marking keyword arguments to functions in Emacs Lisp and Common Lisp, so it does not add completely alien concepts.
</p>

<p>
The inline function call via inline " : " is a limited generalization of using the colon to mark an indentation level: If we add a syntax-element, we should use it as widely as possible to justify adding syntax overhead.
</p>

<p>
But if you need to use <code>:</code> as variable or function name, you can still do so by escaping it with a backslash (<code>\:</code>), so this does not forbid using the character.
</p>

<p>
For simple cases, the colon could be replaced by clever whitespace parsing, but there are complex cases which make this impossible. The minimal example is a theoretical doublelet which does not require a body:<sup><a id="fnr.6" name="fnr.6" class="footref" href="#fn.6">6</a></sup>
</p>

<div class="org-src-container">

<pre class="src src-scheme">(doublelet
  ((foo bar))
  ((bla foo)))
</pre>
</div>

<p>
The wisp version of this is
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">doublelet</span>
<span style="color: #a020f0;">  :</span>
<span style="color: #0000ff;">    foo</span> bar
<span style="color: #a020f0;">  : </span><span style="color: #898887;">; </span><span style="color: #898887;"><- this empty backstep is the real issue</span>
<span style="color: #0000ff;">    bla</span> foo
</pre>
</div>

<p>
or shorter with inline colon (which you can use only if you don’t need further indentation-syntax inside the assignment).
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">doublelet</span>
<span style="color: #a020f0;">  : </span><span style="color: #0000ff;">foo</span> bar
<span style="color: #a020f0;">  : </span><span style="color: #0000ff;">bla</span> foo
</pre>
</div>

<p>
The need to be able to represent arbitrary syntax trees which can contain expressions like this is the real reason, why the colon exists. The inline and start-of-line use is only a generalization of that principle (we add a syntax-element, so we should see how far we can push it to reduce the effective cost of introducing the additional syntax).
</p>
</div>

<div id="outline-container-sec-5-2-1" class="outline-4">
<h4 id="sec-5-2-1"><span class="section-number-4">5.2.1</span> Clever whitespace-parsing which would not work</h4>
<div class="outline-text-4" id="text-5-2-1">
<p>
There are two alternative ways to tackle this issue: deferred level-definition and fixed-width indentation.
</p>

<p>
Defining intermediate indentation-levels by later elements (deferred definition) would be a problem, because it would create code which is really hard to understand. An example is the following:
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span> (<span style="color: #0000ff;">flubb</span>)
<span style="color: #0000ff;">    nubb</span>
<span style="color: #0000ff;">    hubb</span>
<span style="color: #0000ff;">    subb</span>
<span style="color: #0000ff;">   gam</span>
</pre>
</div>

<p>
would become
</p>

<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">flubb</span>)
   ((nubb))
   ((hubb))
   ((subb))
  (gam))
</pre>
</div>

<p>
while
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span> (<span style="color: #0000ff;">flubb</span>)
<span style="color: #0000ff;">    nubb</span>
<span style="color: #0000ff;">    hubb</span>
<span style="color: #0000ff;">    subb</span>
</pre>
</div>

<p>
would become
</p>

<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">flubb</span>)
   (nubb)
   (hubb)
   (subb))
</pre>
</div>

<p>
Knowledge of later parts of the code would be necessary to understand the parts a programmer is working on at the moment. This would call for subtle errors which would be hard to track down, because the effect of a change in code would not be localized at the point where the change is done but could propagate backwards.
</p>

<p>
Fixed indentation width (alternative option to inferring it from later lines) would make it really hard to write readable code. Stuff like this would not be possible:
</p>

<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">when</span>
<span style="color: #0000ff;">    equal?</span> wrong
<span style="color: #0000ff;">           isright?</span> stuff
<span style="color: #0000ff;">    fixstuff</span>
</pre>
</div>
</div>
</div>
</div>

<div id="outline-container-sec-5-3" class="outline-3">
<h3 id="sec-5-3"><span class="section-number-3">5.3</span> _ (the underscore)</h3>
<div class="outline-text-3" id="text-5-3">
<p>
In Python the whitespace hostile html already presents problems with sharing code - for example in email list archives and forums. But Python-programmers can mostly infer the indentation by looking at the previous line: If that ends with a colon, the next line must be more indented (there is nothing to clearly mark reduced indentation, though). In wisp we do not have this support, so we need a way to survive in the hostile environment of todays web.
</p>

<p>
The underscore is commonly used to denote a space in URLs, where spaces are inconvenient, but it is rarely used in Scheme (where the dash ("-") is mostly used instead), so it seems like a a natural choice.
</p>

<p>
You can still use underscores anywhere but at the beginning of the line, and even at the beginning of the line you simply need to escape it by prefixing the first underscore with a backslash ("\____").
</p>
</div>
</div>
</div>

<div id="outline-container-sec-6" class="outline-2">
<h2 id="sec-6"><span class="section-number-2">6</span> Implementation</h2>
<div class="outline-text-2" id="text-6">
<p>
This reference implementation realizes a specialized parser for Scheme. It uses GNU Guile and can also be used at the REPL. 
</p>

<p>
The wisp code also contains a general wisp-preprocessor which can be used for any lisp-like language and can used as an external program which gets called on reading. It does not actually have to understand the code itself. This is not part of this SRFI, though.
</p>

<p>
To allow for easy re-implementation, the chapter after the implementation itself contains a test-suite with commonly used wisp constructs and parenthesized counterparts.
</p>

<p>
The wisp preprocessor implementation can be found at <a href="http://draketo.de/proj/wisp">http://draketo.de/proj/wisp</a>. Both implementations are explicitly licensed to allow inclusion in an SRFI.
</p>
</div>

<div id="outline-container-sec-6-1" class="outline-3">
<h3 id="sec-6-1"><span class="section-number-3">6.1</span> The generic wisp processor (code)</h3>
<div class="outline-text-3" id="text-6-1">
<p>
TODO: Include the code from <a href="http://draketo.de/proj/wisp">http://draketo.de/proj/wisp</a>
</p>
</div>
</div>

<div id="outline-container-sec-6-2" class="outline-3">
<h3 id="sec-6-2"><span class="section-number-3">6.2</span> Test Suite</h3>
<div class="outline-text-3" id="text-6-2">
<p>
The wisp test-suite consists of a large number of wisp-snippets and the corresponding scheme-code. 
</p>

<p>
A wisp-implementation may call itself compliant with the wisp test-suite if the code tree parsed from the wisp file is the same as a code tree parsed from the equivalent Scheme file.
</p>

<p>
A wisp-implementation may call itself a compliant wisp pre-processor if it successfully converts each wisp-snippet into the corresponging scheme-snippet. Blank lines at the end of the file and non-functional white-space in the produced scheme-file do not matter for this purpose.
</p>

<p>
This test-suite is also available in the <a href="http://draketo.de/proj/wisp">wisp repository</a> along with a script-runner (runtests.sh) which tests the reference wisp-implementation with GNU Guile against this testsuite.<sup><a id="fnr.7" name="fnr.7" class="footref" href="#fn.7">7</a></sup>
</p>
</div>

<div id="outline-container-sec-6-2-1" class="outline-4">
<h4 id="sec-6-2-1"><span class="section-number-4">6.2.1</span> tests/syntax-underscore.w</h4>
<div class="outline-text-4" id="text-6-2-1">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">a</span> b c
<span style="color: #0000ff;">_ d</span> e
<span style="color: #0000ff;">___ f</span>
<span style="color: #0000ff;">___</span> g h
<span style="color: #0000ff;">__</span><span style="color: #a020f0;">  . </span>i

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">_</span>
<span style="color: #0000ff;">_  display</span> <span style="color: #C33;">"hello\n"</span>

<span style="color: #0000ff;">\_</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-2" class="outline-4">
<h4 id="sec-6-2-2"><span class="section-number-4">6.2.2</span> tests/syntax-underscore.scm</h4>
<div class="outline-text-4" id="text-6-2-2">
<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">a</span> b c)
  (d e
    (f)
    (g h)
    i))

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">_</span>)
   (display <span style="color: #C33;">"hello\n"</span>))

(_)
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-3" class="outline-4">
<h4 id="sec-6-2-3"><span class="section-number-4">6.2.3</span> tests/syntax-strings-parens.w</h4>
<div class="outline-text-4" id="text-6-2-3">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #898887;">; </span><span style="color: #898887;">Test linebreaks in strings and brackets</span>

<span style="color: #a020f0;">. </span><span style="color: #C33;">"flubbub</span>

<span style="color: #C33;">flabbab"</span>

hrug (<span style="color: #0000ff;">nadda</span>
<span style="color: #0000ff;">madda</span> gadda <span style="color: #C33;">"shoktom</span>
<span style="color: #C33;"> mee"</span>  <span style="color: #C33;">" sep  </span>
<span style="color: #C33;">ka"</span>
<span style="color: #0000ff;">  hadda)</span>
<span style="color: #0000ff;">    gom</span>

<span style="color: #0000ff;">flu</span>

<span style="color: #0000ff;">sum</span> [foo
<span style="color: #0000ff;">bar]</span> barz {1 + [* <span style="color: #008b8b;">2</span> <span style="color: #008b8b;">2</span>]}

<span style="color: #0000ff;">mara</span> {
<span style="color: #0000ff;">li</span>
<span style="color: #0000ff;">+</span>
<span style="color: #0000ff;">lo</span> - (<span style="color: #0000ff;">mabba</span>)
<span style="color: #0000ff;">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-4" class="outline-4">
<h4 id="sec-6-2-4"><span class="section-number-4">6.2.4</span> tests/syntax-strings-parens.scm</h4>
<div class="outline-text-4" id="text-6-2-4">
<div class="org-src-container">

<pre class="src src-scheme"><span style="color: #898887;">; </span><span style="color: #898887;">Test linebreaks in strings and brackets</span>

<span style="color: #C33;">"flubbub</span>

<span style="color: #C33;">flabbab"</span>

(hrug (nadda
madda gadda <span style="color: #C33;">"shoktom</span>
<span style="color: #C33;"> mee"</span>  <span style="color: #C33;">" sep  </span>
<span style="color: #C33;">ka"</span>
  hadda)
    (gom))

(flu)

(sum [foo
bar] barz {1 + [* 2 2]})

(mara {
li
+
lo - (mabba)
})
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-5" class="outline-4">
<h4 id="sec-6-2-5"><span class="section-number-4">6.2.5</span> tests/syntax-indent.w</h4>
<div class="outline-text-4" id="text-6-2-5">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span> 
<span style="color: #0000ff;">  hello</span> who
<span style="color: #0000ff;">  format</span> <span style="color: #008b8b;">#t</span> <span style="color: #C33;">"Hello ~A\n"</span> who

<span style="color: #483d8b;">define</span>
    <span style="color: #483d8b;">let</span>
<span style="color: #a020f0;">      :</span>
<span style="color: #0000ff;">        a</span> <span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">        b</span> <span style="color: #008b8b;">2</span>
<span style="color: #0000ff;">        c</span> <span style="color: #008b8b;">3</span>
<span style="color: #0000ff;">      format</span> <span style="color: #008b8b;">#t</span> <span style="color: #C33;">"a: ~A, b: ~A, c: ~A"</span>
<span style="color: #0000ff;">                   +</span> a <span style="color: #008b8b;">2</span>
<span style="color: #a020f0;">                   . </span>       b      c
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-6" class="outline-4">
<h4 id="sec-6-2-6"><span class="section-number-4">6.2.6</span> tests/syntax-indent.scm</h4>
<div class="outline-text-4" id="text-6-2-6">
<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> 
  (hello who)
  (format #t <span style="color: #C33;">"Hello ~A\n"</span> who))

(<span style="color: #a020f0;">define</span>
    (<span style="color: #a020f0;">let</span>
      (
        (a 1)
        (b 2)
        (c 3))
      (format #t <span style="color: #C33;">"a: ~A, b: ~A, c: ~A"</span>
                   (+ a 2)
                          b      c)))
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-7" class="outline-4">
<h4 id="sec-6-2-7"><span class="section-number-4">6.2.7</span> tests/syntax-empty.w</h4>
<div class="outline-text-4" id="text-6-2-7">
<div class="org-src-container">

<pre class="src src-wisp"></pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-8" class="outline-4">
<h4 id="sec-6-2-8"><span class="section-number-4">6.2.8</span> tests/syntax-empty.scm</h4>
<div class="outline-text-4" id="text-6-2-8">
<div class="org-src-container">

<pre class="src src-scheme"></pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-9" class="outline-4">
<h4 id="sec-6-2-9"><span class="section-number-4">6.2.9</span> tests/syntax-dot.w</h4>
<div class="outline-text-4" id="text-6-2-9">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">foo</span>
<span style="color: #a020f0;">  . </span><span style="color: #C33;">"bar"</span>

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">bar</span>
<span style="color: #0000ff;">  '</span> <span style="color: #008b8b;">1</span>
<span style="color: #a020f0;">    . . </span><span style="color: #008b8b;">2</span> <span style="color: #898887;">; </span><span style="color: #898887;">pair</span>

<span style="color: #0000ff;">display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">foo</span>
<span style="color: #0000ff;">newline</span>
<span style="color: #0000ff;">display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">bar</span>
<span style="color: #0000ff;">newline</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-10" class="outline-4">
<h4 id="sec-6-2-10"><span class="section-number-4">6.2.10</span> tests/syntax-dot.scm</h4>
<div class="outline-text-4" id="text-6-2-10">
<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">foo</span>)
  <span style="color: #C33;">"bar"</span>)

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">bar</span>)
  '(1
    . 2 ))<span style="color: #898887;">; </span><span style="color: #898887;">pair</span>

(display (foo))
(newline)
(display (bar))
(newline)
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-11" class="outline-4">
<h4 id="sec-6-2-11"><span class="section-number-4">6.2.11</span> tests/syntax-colon.w</h4>
<div class="outline-text-4" id="text-6-2-11">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">let</span>
<span style="color: #a020f0;">  :</span>
<span style="color: #0000ff;">    a</span> <span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">    b</span> <span style="color: #008b8b;">2</span>
  <span style="color: #483d8b;">let</span>
<span style="color: #a020f0;">    :</span>
<span style="color: #a020f0;">      :</span>
<span style="color: #a020f0;">        . </span>c <span style="color: #008b8b;">3</span>
<span style="color: #0000ff;">    format</span> <span style="color: #008b8b;">#t</span> <span style="color: #C33;">"a: ~A, b: ~A, c: ~A"</span>
<span style="color: #a020f0;">              . </span>   a      b      c

<span style="color: #a020f0;">: </span>a

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">hello</span>
<span style="color: #0000ff;">  display</span> <span style="color: #C33;">"hello\n"</span>

<span style="color: #483d8b;">let</span>
<span style="color: #a020f0;">  : </span><span style="color: #0000ff;">a</span> <span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">    b</span> <span style="color: #008b8b;">2</span>
<span style="color: #0000ff;">  format</span> <span style="color: #008b8b;">#t</span> <span style="color: #C33;">"a: ~A, b: ~A"</span>
<span style="color: #a020f0;">            . </span>   a      b

<span style="color: #483d8b;">let</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">:</span> a ' :

<span style="color: #483d8b;">let</span> 
<span style="color: #a020f0;">  : </span>   <span style="color: #898887;">; </span><span style="color: #898887;">foo</span>
<span style="color: #0000ff;">    a</span>
      '

<span style="color: #a020f0;">:</span>
  a

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">\:</span>
<span style="color: #0000ff;">  hello</span>

<span style="color: #0000ff;">\:</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-12" class="outline-4">
<h4 id="sec-6-2-12"><span class="section-number-4">6.2.12</span> tests/syntax-colon.scm</h4>
<div class="outline-text-4" id="text-6-2-12">
<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">let</span>
  (
    (a 1)
    (b 2))
  (<span style="color: #a020f0;">let</span>
    (
      (
        c 3))
    (format #t <span style="color: #C33;">"a: ~A, b: ~A, c: ~A"</span>
                 a      b      c)))

((a))

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">hello</span>)
  (display <span style="color: #C33;">"hello\n"</span>))

(<span style="color: #a020f0;">let</span>
  ((a 1)
    (b 2))
  (format #t <span style="color: #C33;">"a: ~A, b: ~A"</span>
               a      b))

(<span style="color: #a020f0;">let</span> ((a '())))

(<span style="color: #a020f0;">let</span> 
  (    <span style="color: #898887;">; </span><span style="color: #898887;">foo</span>
    (a
      '())))

(
  (a))

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">:</span>)
  (hello))

(:)
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-13" class="outline-4">
<h4 id="sec-6-2-13"><span class="section-number-4">6.2.13</span> tests/sublist.w</h4>
<div class="outline-text-4" id="text-6-2-13">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #898887;">; </span><span style="color: #898887;">sublists allow to start single line function calls with a colon ( : ).</span>

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">a</span> b c
  <span style="color: #483d8b;">let</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">:</span> e<span style="color: #a020f0;"> . </span>f
<span style="color: #a020f0;">        . </span>g
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-14" class="outline-4">
<h4 id="sec-6-2-14"><span class="section-number-4">6.2.14</span> tests/sublist.scm</h4>
<div class="outline-text-4" id="text-6-2-14">
<div class="org-src-container">

<pre class="src src-scheme"><span style="color: #898887;">; </span><span style="color: #898887;">sublists allow to start single line function calls with a colon ( : ).</span>

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">a</span> b c)
  (<span style="color: #a020f0;">let</span> ((e . f))
        g))
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-15" class="outline-4">
<h4 id="sec-6-2-15"><span class="section-number-4">6.2.15</span> tests/hashbang.w</h4>
<div class="outline-text-4" id="text-6-2-15">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #898887;">#!/usr/bin/wisp.py # !#</span>
<span style="color: #898887;">; </span><span style="color: #898887;">This tests hashbang lines</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-16" class="outline-4">
<h4 id="sec-6-2-16"><span class="section-number-4">6.2.16</span> tests/hashbang.scm</h4>
<div class="outline-text-4" id="text-6-2-16">
<div class="org-src-container">

<pre class="src src-scheme">#!/usr/bin/wisp.py # !#
<span style="color: #898887;">; </span><span style="color: #898887;">This tests hashbang lines</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-17" class="outline-4">
<h4 id="sec-6-2-17"><span class="section-number-4">6.2.17</span> tests/readable-tests.w</h4>
<div class="outline-text-4" id="text-6-2-17">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">fibfast</span> n
      <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;"><</span> n <span style="color: #008b8b;">2</span>
<span style="color: #a020f0;">      . </span>n           
<span style="color: #0000ff;">      fibup</span> n <span style="color: #008b8b;">2</span> <span style="color: #008b8b;">1</span> <span style="color: #008b8b;">0</span> 

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">fibup</span> maxnum count n-1 n-2
       <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">=</span> maxnum count
<span style="color: #0000ff;">         +</span> n-1  n-2
<span style="color: #0000ff;">         fibup</span> maxnum 
<span style="color: #0000ff;">               +</span> count <span style="color: #008b8b;">1</span> 
<span style="color: #0000ff;">               +</span> n-1 n-2 
<span style="color: #a020f0;">               . </span>n-1

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> n
       <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;"><=</span> n <span style="color: #008b8b;">1</span>
<span style="color: #a020f0;">         . </span><span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">         *</span> n 
<span style="color: #0000ff;">           factorial</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">-</span> n <span style="color: #008b8b;">1</span>

<span style="color: #483d8b;">define</span> (<span style="color: #0000ff;">gcd</span> x y)
       <span style="color: #483d8b;">if</span> (<span style="color: #0000ff;">=</span> y <span style="color: #008b8b;">0</span>)
<span style="color: #a020f0;">       . </span>x
<span style="color: #0000ff;">       gcd</span> y
<span style="color: #0000ff;">         rem</span> x y

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">add-if-all-numbers</span> lst
<span style="color: #0000ff;">       call/cc</span> 
<span style="color: #0000ff;">         lambda</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">exit</span>
                <span style="color: #483d8b;">let</span> loop 
<span style="color: #a020f0;">                  : </span>
<span style="color: #0000ff;">                    lst</span> lst 
<span style="color: #0000ff;">                    sum</span> <span style="color: #008b8b;">0</span>
                  <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">null?</span> lst
<span style="color: #a020f0;">                     . </span>sum
                     <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #483d8b;">not</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">number?</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">car</span> lst
<span style="color: #0000ff;">                        exit</span> <span style="color: #008b8b;">#f</span>
<span style="color: #0000ff;">                        +</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">car</span> lst
<span style="color: #0000ff;">                          loop</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">cdr</span> lst
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-18" class="outline-4">
<h4 id="sec-6-2-18"><span class="section-number-4">6.2.18</span> tests/readable-tests.scm</h4>
<div class="outline-text-4" id="text-6-2-18">
<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">fibfast</span> n)
      (<span style="color: #a020f0;">if</span> (< n 2))
      n           
      (fibup n 2 1 0 ))

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">fibup</span> maxnum count n-1 n-2)
       (<span style="color: #a020f0;">if</span> (= maxnum count)
         (+ n-1  n-2)
         (fibup maxnum 
               (+ count 1 )
               (+ n-1 n-2 )
               n-1)))

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">factorial</span> n)
       (<span style="color: #a020f0;">if</span> (<= n 1)
         1
         (* n 
           (factorial (- n 1)))))

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">gcd</span> x y)
       (<span style="color: #a020f0;">if</span> (= y 0))
       x
       (gcd y
         (rem x y)))

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">add-if-all-numbers</span> lst)
       (<span style="color: #a020f0;">call/cc</span> 
         (<span style="color: #a020f0;">lambda</span> (exit)
                (<span style="color: #a020f0;">let</span> <span style="color: #0000ff;">loop</span> 
                  (
                    (lst lst )
                    (sum 0))
                  (<span style="color: #a020f0;">if</span> (null? lst)
                     sum
                     (<span style="color: #a020f0;">if</span> (not (number? (car lst)))
                        (exit #f)
                        (+ (car lst)
                          (loop (cdr lst)))))))))
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-19" class="outline-4">
<h4 id="sec-6-2-19"><span class="section-number-4">6.2.19</span> tests/quotecolon.w</h4>
<div class="outline-text-4" id="text-6-2-19">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #898887;">#!/home/arne/wisp/wisp-multiline.sh  </span>
<span style="color: #898887;">; </span><span style="color: #898887;">!#</span>
<span style="color: #483d8b;">define</span> a <span style="color: #008b8b;">1</span> <span style="color: #898887;">; </span><span style="color: #898887;">test whether ' : correctly gets turned into '(</span>
<span style="color: #898887;">; </span><span style="color: #898887;">and whether brackets in commments are treated correctly.</span>

<span style="color: #483d8b;">define</span> a '<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">1</span> <span style="color: #008b8b;">2</span> <span style="color: #008b8b;">3</span>

<span style="color: #483d8b;">define</span>
<span style="color: #0000ff;">  a</span> b
<span style="color: #0000ff;">  c</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-20" class="outline-4">
<h4 id="sec-6-2-20"><span class="section-number-4">6.2.20</span> tests/quotecolon.scm</h4>
<div class="outline-text-4" id="text-6-2-20">
<div class="org-src-container">

<pre class="src src-scheme">#!/home/arne/wisp/wisp-multiline.sh  
<span style="color: #898887;">; </span><span style="color: #898887;">!#</span>
(<span style="color: #a020f0;">define</span> <span style="color: #0000ff;">a</span> 1 )<span style="color: #898887;">; </span><span style="color: #898887;">test whether ' : correctly gets turned into '(</span>
<span style="color: #898887;">; </span><span style="color: #898887;">and whether brackets in commments are treated correctly.</span>

(<span style="color: #a020f0;">define</span> <span style="color: #0000ff;">a</span> '(1 2 3))

(<span style="color: #a020f0;">define</span>
  (a b)
  (c))
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-21" class="outline-4">
<h4 id="sec-6-2-21"><span class="section-number-4">6.2.21</span> tests/namedlet.w</h4>
<div class="outline-text-4" id="text-6-2-21">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #898887;">#!/home/arne/wisp/wisp-multiline.sh  </span>
<span style="color: #898887;">; </span><span style="color: #898887;">!#</span>
<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">hello</span> who
<span style="color: #0000ff;">  display</span> who

<span style="color: #483d8b;">let</span> hello
<span style="color: #a020f0;">  : </span><span style="color: #0000ff;">who</span> <span style="color: #008b8b;">0</span>
  <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">=</span> who <span style="color: #008b8b;">5</span>
<span style="color: #0000ff;">    display</span> who
<span style="color: #0000ff;">    hello</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">+</span> <span style="color: #008b8b;">1</span> who
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-22" class="outline-4">
<h4 id="sec-6-2-22"><span class="section-number-4">6.2.22</span> tests/namedlet.scm</h4>
<div class="outline-text-4" id="text-6-2-22">
<div class="org-src-container">

<pre class="src src-scheme">#!/home/arne/wisp/wisp-multiline.sh  
<span style="color: #898887;">; </span><span style="color: #898887;">!#</span>
(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">hello</span> who)
  (display who))

(<span style="color: #a020f0;">let</span> <span style="color: #0000ff;">hello</span>
  ((who 0))
  (<span style="color: #a020f0;">if</span> (= who 5)
    (display who)
    (hello (+ 1 who))))
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-23" class="outline-4">
<h4 id="sec-6-2-23"><span class="section-number-4">6.2.23</span> tests/flexible-parameter-list.w</h4>
<div class="outline-text-4" id="text-6-2-23">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #898887;">; </span><span style="color: #898887;">Test using a . as first parameter on a line by prefixing it with a second .</span>
<span style="color: #483d8b;">define</span>
<span style="color: #0000ff;">  a</span> i
<span style="color: #a020f0;">    . . </span>b
<span style="color: #0000ff;">  unless</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">>=</span> i<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">length</span> b
<span style="color: #0000ff;">    display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">number->string</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">length</span> b 
<span style="color: #0000ff;">    display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">list-ref</span> b i
<span style="color: #0000ff;">    newline</span>
<span style="color: #0000ff;">    apply</span> a ( <span style="color: #0000ff;">+</span> i <span style="color: #008b8b;">1</span> ) b


<span style="color: #0000ff;">a</span> <span style="color: #008b8b;">0</span> <span style="color: #C33;">"123"</span> <span style="color: #C33;">"345"</span> <span style="color: #C33;">"567"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-24" class="outline-4">
<h4 id="sec-6-2-24"><span class="section-number-4">6.2.24</span> tests/flexible-parameter-list.scm</h4>
<div class="outline-text-4" id="text-6-2-24">
<div class="org-src-container">

<pre class="src src-scheme"><span style="color: #898887;">; </span><span style="color: #898887;">Test using a . as first parameter on a line by prefixing it with a second .</span>
(<span style="color: #a020f0;">define</span>
  (a i
    . b)
  (unless (>= i (length b))
    (display (number->string (length b )))
    (display (list-ref b i))
    (newline)
    (apply a ( + i 1 ) b)))


(a 0 <span style="color: #C33;">"123"</span> <span style="color: #C33;">"345"</span> <span style="color: #C33;">"567"</span>)
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-25" class="outline-4">
<h4 id="sec-6-2-25"><span class="section-number-4">6.2.25</span> tests/factorial.w</h4>
<div class="outline-text-4" id="text-6-2-25">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #898887;">;; </span><span style="color: #898887;">short version</span>
<span style="color: #898887;">; </span><span style="color: #898887;">note: once you use one inline colon, all the following forms on that</span>
<span style="color: #898887;">; </span><span style="color: #898887;">line will get closed at the end of the line</span>

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> n
  <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">zero?</span> n
<span style="color: #a020f0;">    . </span><span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">    *</span> n<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">-</span> n <span style="color: #008b8b;">1</span>

<span style="color: #0000ff;">display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> <span style="color: #008b8b;">5</span> 


<span style="color: #898887;">;; </span><span style="color: #898887;">more vertical space, less colons</span>
<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> n
  <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">zero?</span> n
<span style="color: #a020f0;">    . </span><span style="color: #008b8b;">1</span>
<span style="color: #0000ff;">    *</span> n 
<span style="color: #0000ff;">      factorial</span> 
<span style="color: #0000ff;">        -</span> n <span style="color: #008b8b;">1</span>

<span style="color: #0000ff;">display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> <span style="color: #008b8b;">5</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-26" class="outline-4">
<h4 id="sec-6-2-26"><span class="section-number-4">6.2.26</span> tests/factorial.scm</h4>
<div class="outline-text-4" id="text-6-2-26">
<div class="org-src-container">

<pre class="src src-scheme"><span style="color: #898887;">;; </span><span style="color: #898887;">short version</span>
<span style="color: #898887;">; </span><span style="color: #898887;">note: once you use one inline colon, all the following forms on that</span>
<span style="color: #898887;">; </span><span style="color: #898887;">line will get closed at the end of the line</span>

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">factorial</span> n)
  (<span style="color: #a020f0;">if</span> (zero? n)
    1
    (* n (factorial (- n 1)))))

(display (factorial 5 ))


<span style="color: #898887;">;; </span><span style="color: #898887;">more vertical space, less colons</span>
(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">factorial</span> n)
  (<span style="color: #a020f0;">if</span> (zero? n)
    1
    (* n 
      (factorial 
        (- n 1)))))

(display (factorial 5 ))
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-27" class="outline-4">
<h4 id="sec-6-2-27"><span class="section-number-4">6.2.27</span> tests/example.w</h4>
<div class="outline-text-4" id="text-6-2-27">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #483d8b;">define</span> (<span style="color: #0000ff;">a</span> b c)
  <span style="color: #483d8b;">let</span>
<span style="color: #a020f0;">    : </span>
<span style="color: #0000ff;">      d</span> <span style="color: #C33;">"i am a string</span>
<span style="color: #C33;">do not break me!"</span>
<span style="color: #a020f0;">      : </span>
  <span style="color: #898887;">; </span><span style="color: #898887;">comment: 0</span>
        f
<span style="color: #898887;">; </span><span style="color: #898887;">comment : 1</span>
<span style="color: #0000ff;">        `</span> g <span style="color: #898887;">; </span><span style="color: #898887;">comment " : " 2</span>
<span style="color: #a020f0;">      : </span>
<span style="color: #0000ff;">        h</span> (<span style="color: #0000ff;">I</span> am in brackets:
<span style="color: #0000ff;">           do</span> <span style="color: #483d8b;">not</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">change</span> <span style="color: #C33;">"me"</span>)
<span style="color: #a020f0;">        . </span>i
<span style="color: #0000ff;">  ,</span><span style="color: #008b8b;"> 'j</span> k

<span style="color: #a020f0;">  . </span>l

<span style="color: #898887;">; </span><span style="color: #898887;">comment</span>

<span style="color: #0000ff;">  a</span> c

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">b</span> :n o
<span style="color: #a020f0;">  . </span><span style="color: #C33;">"second defun : with a docstring!"</span>
<span style="color: #0000ff;">  message</span> <span style="color: #C33;">"I am here"</span>
<span style="color: #a020f0;">  . </span>t

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">c</span> e f
<span style="color: #a020f0;">  : </span><span style="color: #0000ff;">g</span>
<span style="color: #a020f0;">  :</span>
<span style="color: #0000ff;">    h</span>
<span style="color: #0000ff;">      i</span>
<span style="color: #0000ff;">    j</span>
<span style="color: #0000ff;">  '</span> :
<span style="color: #0000ff;">  k</span>
<span style="color: #a020f0;">  . </span>l
<span style="color: #a020f0;">  . </span>: <span style="color: #0000ff;">m</span>

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">_</span> \:
<span style="color: #0000ff;">__</span>
<span style="color: #0000ff;">__</span><span style="color: #a020f0;"> . </span>\:

<span style="color: #0000ff;">\_</span> b

<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">d</span> 
      <span style="color: #483d8b;">let</span> 
<span style="color: #a020f0;">          : </span><span style="color: #0000ff;">a</span> b
<span style="color: #0000ff;">            c</span> d

<span style="color: #0000ff;">a</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">:</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">c</span>

<span style="color: #483d8b;">let</span> 
<span style="color: #a020f0;">    : </span><span style="color: #0000ff;">a</span> b
      c

<span style="color: #483d8b;">let</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">:</span> a b

<span style="color: #a020f0;">. </span>a
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-28" class="outline-4">
<h4 id="sec-6-2-28"><span class="section-number-4">6.2.28</span> tests/example.scm</h4>
<div class="outline-text-4" id="text-6-2-28">
<div class="org-src-container">

<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">a</span> b c)
  (<span style="color: #a020f0;">let</span>
    (
      (d <span style="color: #C33;">"i am a string</span>
<span style="color: #C33;">do not break me!"</span>)
      (
  <span style="color: #898887;">; </span><span style="color: #898887;">comment: 0</span>
        (f)
<span style="color: #898887;">; </span><span style="color: #898887;">comment : 1</span>
        `(g ))<span style="color: #898887;">; </span><span style="color: #898887;">comment " : " 2</span>
      (
        (h (I am in brackets:
           do not : change <span style="color: #C33;">"me"</span>))
        i)))
  ,('j k)

  l

<span style="color: #898887;">; </span><span style="color: #898887;">comment</span>

  (a c))

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">b</span> <span style="color: #483d8b;">:n</span> o)
  <span style="color: #C33;">"second defun : with a docstring!"</span>
  (message <span style="color: #C33;">"I am here"</span>)
  t)

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">c</span> e f)
  ((g))
  (
    (h
      (i))
    (j))
  '(())
  (k)
  l
  (m))

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">_</span> :)

   :)

(_ b)

(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">d</span>)
      (<span style="color: #a020f0;">let</span> 
          ((a b)
            (c d))))

(a (((c))))

(<span style="color: #a020f0;">let</span> 
    ((a b)
      (c)))

(<span style="color: #a020f0;">let</span> ((a b)))

a
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-29" class="outline-4">
<h4 id="sec-6-2-29"><span class="section-number-4">6.2.29</span> tests/continuation.w</h4>
<div class="outline-text-4" id="text-6-2-29">
<div class="org-src-container">

<pre class="src src-wisp"><span style="color: #0000ff;">a</span> b c d e
<span style="color: #a020f0;">  . </span>f g h
<span style="color: #a020f0;">  . </span>i j k

<span style="color: #0000ff;">concat</span> <span style="color: #C33;">"I want "</span> 
<span style="color: #0000ff;">    getwish</span> from me
<span style="color: #a020f0;">    . </span><span style="color: #C33;">" - "</span> username
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-6-2-30" class="outline-4">
<h4 id="sec-6-2-30"><span class="section-number-4">6.2.30</span> tests/continuation.scm</h4>
<div class="outline-text-4" id="text-6-2-30">
<div class="org-src-container">

<pre class="src src-scheme">(a b c d e
  f g h
  i j k)

(concat <span style="color: #C33;">"I want "</span> 
    (getwish from me)
    <span style="color: #C33;">" - "</span> username)
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="outline-container-sec-7" class="outline-2">
<h2 id="sec-7"><span class="section-number-2">7</span> Copyright</h2>
<div class="outline-text-2" id="text-7">
<p>
Copyright (C) Arne Babenhauserheide (2013–2014). All Rights Reserved.
</p>

<p>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
</p>

<p>
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
</p>

<p>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</p>
</div>
</div>
<div id="footnotes">
<h2 class="footnotes">Footnotes: </h2>
<div id="text-footnotes">

<div class="footdef"><sup><a id="fn.1" name="fn.1" class="footnum" href="#fnr.1">1</a></sup> <p class="footpara">
The most common non-letter, non-math characters in prose are <code>.,":'_#?!;</code>, in the given order as derived from newspapers and other sources (for the ngram assembling scripts, see the <a href="http://bitbucket.org/ArneBab/evolve-keyboard-layout">evolve keyboard layout project</a>).
</p></div>

<div class="footdef"><sup><a id="fn.2" name="fn.2" class="footnum" href="#fnr.2">2</a></sup> <p class="footpara">
Typed Racket uses calls of the form <code>(: x Number)</code> to declare types. These forms can still be used directly in parenthesized form, but in wisp-form the colon has to be replaced with <code>\:</code>.
</p></div>

<div class="footdef"><sup><a id="fn.3" name="fn.3" class="footnum" href="#fnr.3">3</a></sup> <p class="footpara">
In most cases type-declarations are not needed in typed racket, since the type can be inferred. See <a href="http://docs.racket-lang.org/ts-guide/more.html?q=typed#(part._when-annotations~3f)">When do you need type annotations?</a>
</p></div>

<div class="footdef"><sup><a id="fn.4" name="fn.4" class="footnum" href="#fnr.4">4</a></sup> <p class="footpara">
Conceptually, continuing the argument list with a period uses syntax to mark the rare case of not calling a function as opposed to marking the common case of calling a function. To back the claim, that calling a function is actually the common case in scheme-code, grepping the the modules in the Guile source code shows over 27000 code-lines which start with a paren and only slightly above 10000 code-lines which start with a non-paren, non-comment character. Since wisp-syntax mostly follows the regular scheme indentation guidelines (as realized for example by emacs), the whitespace in front of lines does not need to change.
</p></div>

<div class="footdef"><sup><a id="fn.5" name="fn.5" class="footnum" href="#fnr.5">5</a></sup> <p class="footpara">
This special syntax for double parens cannot be replaced by clever whitespace parsing, because it is required for representing two consecutive forms which start with double parentheses. The only pure-whitespace alternative would be fixed-width indentation levels.
</p></div>

<div class="footdef"><sup><a id="fn.6" name="fn.6" class="footnum" href="#fnr.6">6</a></sup> <p class="footpara">
The example uses a double let without action as example for the colon-syntax, even though that does nothing, because that makes it impossible to use later indentation to mark an intermediate indentation-level. Another reason why I would not use later indentation to define whether something earlier is a single or double indent is that this would call for subtle and really hard to find errors.
</p></div>

<div class="footdef"><sup><a id="fn.7" name="fn.7" class="footnum" href="#fnr.7">7</a></sup> <p class="footpara">
To run the tests in the wisp testsuite with a separately built GNU Guile, you can use any given guile interpreter by adjusting the following command: <code>PATH=~/guile-2.0.11/meta:${PATH} ./runtests.sh</code>
</p></div>


</div>
</div></div>
<div id="postamble" class="status">
<p class="author">Author: Arne Babenhauserheide</p>
<p class="date">Created: 2014-12-23 Di 17:17</p>
<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.4.1 (<a href="http://orgmode.org">Org</a> mode 8.2.6)</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>