Last active
December 11, 2015 16:58
-
-
Save SaitoAtsushi/4630851 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
#!r6rs | |
(library (bound helper) | |
(export make-definition) | |
(import (rnrs)) | |
(define-syntax make-definition | |
(lambda(stx2) | |
(syntax-case stx2 () | |
((_ if-bound bound?) | |
#'(begin | |
(define-syntax if-bound | |
(lambda(stx) | |
(syntax-case stx () | |
((_ id consequent) | |
#'(if-bound id consequent #f)) | |
((_ id consequent alternate) | |
(not | |
(free-identifier=? | |
(datum->syntax #'if-bound (syntax->datum #'id)) | |
#'id)) | |
#'consequent) | |
((_ id consequent alternate) | |
#'alternate)))) | |
(define-syntax bound? | |
(syntax-rules () | |
((_ id) | |
(if-bound id #t #f))))))))) | |
) | |
(library (bound) | |
(export bound? if-bound) | |
(import (bound helper)) | |
(make-definition if-bound bound?) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment