(defmacro λ (&rest symbols-and-expr) `(lambda ,(butlast symbols-and-expr) ,@(last symbols-and-expr))) (mapcar (λ x (* x x)) '(1 2 3 4)) ;; other tremendously useful characters: '|αβγδεζηθικλμνξοπρστυϕχψω| '|ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥϕΧΨΩ| '|ℝℕℤℚ∥√∡∞∝ℵ∅∫| '|¬∀∃∨∧⊥∈⊂∪∩⇐⇔⇒↦|
This means you can finally use fancy Greek and Logical symbols in your Lisp programs without sacrificing portability! However you should check with your coworkers first. Not everyone is comfortable producing such symbols on a computer (a terrible regression with respect to handwritten text). Practical mechanisms to enter Unicode symbols an a computer are:
- An extended keyboard layout like Neo.
- Configure your editor to fold certain strings to Unicode symbols (e.g. abbrev-mode in Emacs).
- Look up the character in a table, e.g. with C-x 8 RET in Emacs, or by copying it from Wikipedia. (This methods are quite annoying and should only be used in exceptional circumstances)
Implementation Details
While the core functionality is the same across all Lisp implementations --- Unicode characters are a subtype of CHARACTER --- no two implementations are alike when it comes to the details.
ABCL
- Uses the underlying String type of Java, a 16-bit per character encoding
- Official Documentation
ACL
CCL
- Internal representation: UTF-32
- Official Documentation
CMUCL
- First version with Unicode support: 20A
- Internal representation: UTF-16
- Official Documentation
ECL
- Internal representation: 24bits/character
- Official Documentation
LispWorks
SBCL
- First version with Unicode support: 0.8.17
- Build-time option :SB-UNICODE (enabled by default) for building the system with support for the entire 21-bit character space defined by the Unicode consortium.
- Has a build-time option (controlled by the :SB-UNICODE keyword feature, enabled by default) for building the system with support for the entire 21-bit character space defined by the Unicode consortium.
- Details are explained on the sbcl-internals cliki, or this presentation from Christophe Rhodes, which he presented at the European Common Lisp Meeting, April 2005
- Official Documentation
CLISP
- First version with Unicode support: 2.31
- Ability to pass multibyte encodings via FFI since version 2.35
programming tips