Created
December 29, 2017 18:30
-
-
Save vyzo/2945f7de5f6d88f46f2416438f8823d8 to your computer and use it in GitHub Desktop.
This file contains 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
(defsyntax (let-hash stx) | |
(syntax-case stx () | |
((macro expr body ...) | |
(with-syntax ((@ref (stx-identifier #'macro '%%ref))) | |
#'(let (hash expr) | |
(let-syntax | |
((var-ref | |
(syntax-rules () | |
((_ id) (@ref id))))) | |
(let-syntax | |
((@ref | |
(lambda (stx) | |
(syntax-case stx () | |
((_ id) | |
(let (str (symbol->string (stx-e #'id))) | |
(if (eq? (string-ref str 0) #\.) | |
(with-syntax ((sym (string->symbol (substring str 1 (string-length str))))) | |
(if (eq? (string-ref str 1) #\.) | |
;; quoted (multiple dots) | |
#'(var-ref sym) | |
#'(hash-ref hash 'sym))) | |
#'(var-ref id)))))))) | |
body ...))))))) |
Author
vyzo
commented
Feb 1, 2018
It's in :std/sugar
as of mighty-gerbils/gerbil@f99f38d.
Example usage: https://github.com/vyzo/gerbil/blob/master/src/tools/gxpkg.ss#L85
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment