Created
May 1, 2010 08:01
-
-
Save kana/386143 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
; How do I implement the following macro in R5RS? | |
; | |
; (define! x) | |
; ==> (define x "x") | |
; (define x "x!") | |
(define-syntax define! | |
(syntax-rules () | |
[(_ name) | |
(define name (symbol->string 'name)) | |
(define ... ...)])) |
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
; In Gauche. | |
; But it's ugly. Isn't there smarter solution? | |
(define-syntax define! | |
(syntax-rules () | |
[(_ name) | |
(let1 name!s (string-append (symbol->string 'name) "!") | |
(map (cut eval <> (current-module)) | |
`((define ,(string->symbol name!s) ,name!s) | |
(define name (symbol->string 'name)))))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment