-
-
Save youz/6b3604e524c1636a03e1a3444158ea20 to your computer and use it in GitHub Desktop.
#,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun shecomma-reader (stream sub-character n) | |
(declare (ignore sub-character)) | |
(let ((a (gensym "A")) | |
(f (read stream nil nil))) | |
`(lambda (&rest ,a) | |
(apply ,(case n | |
(0 `(quote ,f)) | |
(1 f) | |
(t `(function ,f))) | |
,a)))) | |
(set-dispatch-macro-character #\# #\, #'shecomma-reader) | |
(defun f (n) (/ n 4)) | |
(flet ((f (x) (* 2 x))) | |
(let ((f (lambda (x) (* 3 x)))) | |
(values (#,f 1) (#0,f 1) (#1,f 1) (#2,f 1)))) | |
;; -> 2, 1/4, 3, 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment