Skip to content

Instantly share code, notes, and snippets.

@shanecelis
Created August 29, 2013 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanecelis/6381180 to your computer and use it in GitHub Desktop.
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
(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