Created
June 8, 2012 19:22
-
-
Save danking/2897687 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
| (define-struct just-a-function ([l #:mutable] r) #:property prop:procedure 2) | |
| (define (define#-help proc) | |
| (let* ((me (box #f)) | |
| (f (just-a-function proc (lambda args (apply (just-a-function-l (unbox me)) args))))) | |
| (set-box! me f) | |
| (values f (lambda (new-proc) (set-just-a-function-l! f new-proc))))) | |
| (define-syntax define# (syntax-rules () ((_ ((name magic) args ...) body) | |
| (define-values (name magic) | |
| (define#-help (lambda (args ...) body)))))) | |
| (define# ((foo magic) x) (sqr x)) | |
| (foo 9) | |
| (magic sqrt) | |
| (foo 9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment