Home of various Common Lisp syntax extensions and utilities
Having a custom syntax may be useful to simplify typing and also to help code readability. Readability is helped by removing unnecessary noise and giving a given construct a distinct visual representation that is easier to be processed by the pattern matcher in our brains (well, mine at least). This projects aims to
You can find a few examples of the supported syntaxes below. The API of each syntax consist of three different entries:
(enable-readtime-wrapper-syntax #\{ #\}) {with-sharp-boolean-syntax (and #t (or #f #t))}
The list of available syntaxes at the time of writing with some examples (consult the code and the testsuite for the details):
CL-SYNTAX-SUGAR-TEST> (enable-readtime-wrapper-syntax #\{ #\}) ; No value CL-SYNTAX-SUGAR-TEST> {(with-package :cl-walker) '(foo bar baz)} (CL-WALKER::FOO CL-WALKER::BAR CL-WALKER::BAZ)
CL-SYNTAX-SUGAR-TEST> '{(with-quasi-quote-syntax 'my-quote 'my-unquote :quasi-quote-character #\[ :quasi-quote-end-character #\] :unquote-character #\, :splice-character #\@) [1 2 ,3 ,@`(foo ,(call-bar)) 5]} (MY-QUOTE (1 2 (MY-UNQUOTE 3 NIL) (MY-UNQUOTE `(FOO ,(CALL-BAR)) T) 5))
CL-SYNTAX-SUGAR-TEST> (set-lambda-with-bang-args-syntax-in-readtable :start-character #\[ :end-character #\]) ; No value CL-SYNTAX-SUGAR-TEST> (funcall [+ !1 40] 2) 42 CL-SYNTAX-SUGAR-TEST> (funcall [concatenate 'string !2 "-bar-" !1] "baz" "foo") "foo-bar-baz" CL-SYNTAX-SUGAR-TEST> (set-lambda-with-bang-args-syntax-in-readtable :dispatch-character #\# :sub-dispatch-character #\L) ; No value CL-SYNTAX-SUGAR-TEST> (funcall #L(+ !1 40) 2) 42
CL-SYNTAX-SUGAR-TEST> (set-feature-cond-syntax-in-readtable) ; No value CL-SYNTAX-SUGAR-TEST> #*(((and :sbcl (stringp 42)) "silly example") (:sbcl "sbcl is my primary lisp") (:clisp "i need threads...") (t "hm, seems like we are neither on sbcl or clisp...")) "sbcl is my primary lisp" CL-SYNTAX-SUGAR-TEST>
You can browse the cl-syntax-sugar darcs repository or get the tree with
darcs get --partial http://common-lisp.net/project/cl-syntax-sugar/darcs/cl-syntax-sugar
BSD / Public Domain