Alt-Exp: Alternate Syntax for Scheme

 

Description

Alt-Exp is an alternate syntax for S-Expression languages, such as LISP, Scheme, and Racket. It allows the removal of many obviously-implied parenthesis, but it also has an obvious, direct correlation to the equivalent s-expression so it already works with existing libraries and even macros.

For example, consider the following comparisons.

(let ([a 1]
      [b 2]
      [c 3])
    (+ a b c))
let: :[a 1]
      [b 2]
      [c 3]
    +(a b c)
(define (what? thing)
  (match thing
    ["a" display("Thing A\n")]
    ["b" display("Thing B\n")]
    [else display("Unknown\n")]))
define: what?(thing)
  match(thing):
   ["a" display("Thing A\n")]
   ["b" display("Thing B\n")]
   [else display("Unknown\n")]
(define: (! n)
  (let loop ([ans 1]
             [n n])
      (if (equal? n 0)
          ans
          (loop (* ans n) (n . - . 1)))))
define: !(n)
  let: loop :ans: 1
             n: n
      if: {n equal? 0}
          ans
          loop({ans * n} {n - 1})
((lambda (x) x) 1)
_(lambda: [x] x)(1)
((lambda (x) (x x)) 
 (lambda (x) (x x)))
_(lambda: [x] x(x))
 (lambda: [x] x(x))

The provided source code contains a reader and a "#lang" language for Racket. To use the language, you need to copy the alt-exp folder into the "collects" folder. There are also a few test examples showing how the language can be used.

Files

Source (.tgz)11 KBalt-exp.tgz