syrup/README.md

1.2 KiB

syrup: assorted syntactic sugar for Lisp

Syrup is a simple package providing syntax enhancements to Common Lisp.

Right now it doesn't do much, but I'll add new features as I think of them.

  • #^sym to export a symbol inline
    • Multi-file projects using this syntax should probably also use (syrup:defpackage*)
  • [] and {} can be used in place of normal parentheses
  • #"" strings for escape sequences and interpolation
    • \~3,'0D(expr): formatted interpolated value (the ~3,'0D part can be any valid (format) directive)
    • \n, \t, \r, \f, \b, \a, and \e
    • \777: octal character codes
    • \xFF, \x{10FFFF}, \U+10FFFF: hex character codes
    • \N{greek small letter phi}: named characters
    • \<Newline> to skip a chunk of whitespace
    • \cX for control codes (e.g. \cA = Start of Heading)
  • (syrup:if*) macro for easier-to-read conditional statements
    (if* (< x 5)
      (format t "x is less than 5!~%")
      (:else-if (< x 20)
        (format t "x is at least 5, but less than 20~%"))
      (:else
        (format t "x is 20 or more~%")))
    
  • (syrup:curry) to create partially-specified functions
    (curry (subseq * 2 *)) ; => (lambda (a b) (subseq a 2 b))