Un-Common Lisp on Common Lisp
Common Lisp
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.sbclrc.example
README.markdown
alias.lisp
anonym-function.lisp
contrib.lisp
debug.lisp
defmacro.lisp
double-dot.lisp
hash-reader.lisp
helper.lisp
package.lisp
ppcre.lisp
reader.lisp
sb-eval.lisp
sb-reader.lisp
sharp-backquote.lisp
special-form.lisp
string.lisp
uncl.asd

README.markdown

Un-Common Lisp

Un-Common Lisp is a new dialect of Lisp.

Dependencies

UnCL only works on SBCL.
Depends on cl-ppcre, cl-interpol, cl-utilities and named-readtables.

Installation

(require 'asdf) ;; You should put this your .sbclrc, if not yet.
(require 'asdf-install)
(asdf-install:install "http://github.com/fukamachi/uncl/tarball/master")

How to use?

Put the following lines to your .sbclrc to try.

(require 'uncl)
(in-package :uncl-user)

;; Putting some reader macros to the readtable.
;; For detail, see following "Features" section.
(enable-uncl-syntax)

If you would determine to use UnCL in your cool application, just replace (:use :cl) to (:use :uncl) in defpackage.

(defpackage your-package
  (:use :uncl))
(enable-uncl-syntax)

Features

Renamed built-in

lambda is too long to type. UnCL have, so as modern dialects of Lisp do, fn instead.

* (fn (x) (* x 2))
=> #<FUNCTION (lambda (x)) {12DD32B5}>

This example can also be written below.

* [* _ 2]
=> #<FUNCTION (lambda (_)) {12B9844D}>
  • suffix "-p" -> "?"
  • prefix "n" -> suffix "!"

More powerful

defmacro* has auto-gensym syntax.

;; THIS IS A EXAMPLE FOR A EXAMPLE
(defmacro* 1+10x (n%)
  `(let ((,num# (* 10 ,n#)))
     (1+ ,num#)))

symbol% is executed only once, and symbol# is going to be expanded to gensym one.

let* destructure it's arguments if need it.

(let* (x 1
       (y z) (list x 20))
  (+ x y z))
=> (+ 1 1 20)
=> 22

More anaphoric

UnCL's if is anaphoric one.

(if (find-user 10)
  (get-name it) ;; `it' refers a result of the conditional part
  'not-found)

So are cond and and.

Keyword as a hash reader

(:a #{:a 10})
=> 10
(call :a #{:a 100})
=> 100

Useful functions

Double dot

(0.. 10)
=> (0 1 2 3 4 5 6 7 8 9 10)
(mapcar [* _ 2] (1.. 10))
=> (2 4 6 8 10 12 14 16 18 20)
(let (start 18 end 20)
  (n.. start end))
=> (18 19 20)

FAQ

Q: How do you pronounce UnCL?
A: Same as "uncle".

License

Copyright (c) 2010 深町英太郎 (E.Fukamachi).
Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)