[plt-scheme] lazy require

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Jul 6 12:18:49 EDT 2009

On Jul  6, Rommel M. Martinez wrote:
> Hi! Does PLT Scheme have an equivalent for a "lazy require"
> functionality, wherein a module only gets loaded, or require'd if a
> symbol provided/exported by that module is referenced?

No, but it would be easy to write your own wrapper, something like

  (define-syntax-rule (define-autoload name reqspec)
    (define name
      (lambda args
        (set! name (dynamic-require 'reqspec 'name))
        (apply name args))))

You can also do that for non-function values, by using identifier

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.