Created
August 29, 2013 17:48
-
-
Save shanecelis/6381180 to your computer and use it in GitHub Desktop.
Derivative of make-trampoline by Mark Weaver from #guile on irc.freenode.net
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
(define (make-trampoline module name) | |
"Creates a trampoline out of a symbol in a given module, e.g. (lambda () (name))" | |
(let ((var (module-variable module name))) | |
(unless var | |
(scm-error 'no-such-variable "make-trampoline" "Can't make a trampoline for variable named '~a that does not exist in module ~a." (list name module) #f)) | |
(let ((proc (lambda () ((variable-ref var))))) | |
(set-procedure-property! proc 'name | |
(string->symbol (format #f "~a-trampoline" name))) | |
proc))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment