Friedrich Dominicus <email@example.com.NO-spam> wrote:
| firstname.lastname@example.org (James McCarron) writes:
| > but all still require explicitly loading something. It's such an
| > "obvious" thing to do, I wonder if there is anything in the semantics
| > of Scheme that would make this invalid or more difficult than I think?
| I guess that it very Scheme Implementation dependent. IIRC SCSH comes
| with something like (require 'whatever) and if whatever is not loaded
| it is loaded from a file. In DrScheme the thing is called
| (require-library or the like.
All of the "requireXXX" functionality I've seen (including SCM's, Scsh's,
and MzScheme's) loads the "require"d file or library, regardless of whether
anything in the file/library is ever used or not. This can significantly
slow down the startup time of an application that provides a *large* number
of seldom-used features.
On the other hand, Elk, while it also provides "require", also offers a
facility called "auto-loading", wherein a symbol is "registered" as being
an autoload symbol with (autoload 'sym "filename"). The filename isn't
loaded, however, until the symbol is first evaluated. E.g.:
% cat foo.scm
(define foo 37)
> (autoload 'foo "foo.scm")
> (+ foo 4)
The initial "autoload" call is very cheap. The cost of the load of the
file is deferred until later... or possibly never, if the symbol is never
Other implementations probably also provide some form of autoloading.
Elk is just the one I'm most familiar with...
Rob Warnock, 41L-955 email@example.com
Applied Networking http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673
1600 Amphitheatre Pkwy. PP-ASEL-IA
Mountain View, CA 94043