CL-2DSYNTAX

The cl-2dsyntax is an indentation-sensitive reader system. Published in the public domain. Because lispers read the code by indentation and not by parentheses, I've decided to write a reader macro for this.

It's up to you when to use this, I'm going to use it in a dumb editor such the Notepad (when I can't choose better).

Download

The asdf-installable package: cl-2dsyntax.tar.gz

Usage

After evaluation of the (enable-syntax) form, the reader macro is hooked on the char #\!.

After #\! it reads input until #\Newline followed by non #\Space character. If the input is only one line it's transformed into list, which is evaluated.

The form:

!+ 1 2 3

transforms into:

(+ 1 2 3)

The first line is skipped if it's empty:

!
* 1
  2
  3

Multi-line input is transformed in this way:

Some example:

!let !!a "Hello "
      !b "world!"
 !concatenate 'string a b

or:

!let !a
         "Hello "
      (b "world!")
 concatenate
  'string a b

Samples

A factorial function:

!defun fact !n
  if !zerop n
    1
    !* n !fact !1- n

or another version:

!defun fact (n)
  if (zerop n)
    1
    * n
      fact
        1-
          n

Implementation of the once-only macro:

!defmacro once-only !(&rest names) &body body
  let !!gensyms !loop for n in names collect !gensym
   `!let !,@!loop for g in gensyms collect `!,g !gensym
      `!let !,,@!loop for g in gensyms for n in names collect ``!,,g ,,n
         ,!let !,@!loop for n in names for g in gensyms collect `!,n ,g
            ,@body