Skip to content

Instantly share code, notes, and snippets.

@youz
Created May 7, 2010 11:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youz/393310 to your computer and use it in GitHub Desktop.
Save youz/393310 to your computer and use it in GitHub Desktop.
short aliases for lambda expression
;;; ref. http://blog.practical-scheme.net/gauche/20100428-shorter-names
;;; http://d.hatena.ne.jp/higepon/20100511/1273584001
#+:xyzzy
(require 'cmu_loop)
(defmacro ^ (args . body)
`(lambda ,args ,@body))
(defmacro define-caret-macros (chars)
(flet ((reread (&rest args)
(read-from-string (format nil "~{~A~}" args))))
`(progn
,@(loop for c across chars
for macsym = (reread '^ c)
for argsym = (reread c)
for macsym* = (reread '^ c '*)
for argsym* = (reread c '*)
collect
`(defmacro ,macsym (&body body)
(let ((#1=#:arg ',argsym))
`(lambda (,#1#) ,@body)))
collect
`(defmacro ,macsym* (&body body)
(let ((#1# ',argsym*))
`(lambda (&rest ,#1#) ,@body)))))))
(define-caret-macros
"_abcdefghijklmnopqrstuvwxyz")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment