Subject: Re: Library facilities for Scheme?...
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 2000/07/07
Newsgroups: comp.lang.scheme
Message-ID: <8k4985$2kmdv$1@fido.engr.sgi.com>
Friedrich Dominicus  <frido@q-software-solutions.com.NO-spam> wrote:
+---------------
| jmccarro@world.std.com (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)

	% elk
	> (autoload 'foo "foo.scm")
	foo
	> (+ foo 4)
	[Autoloading foo.scm]
	41
	> 

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
referenced.

Other implementations probably also provide some form of autoloading.
Elk is just the one I'm most familiar with...


-Rob

-----
Rob Warnock, 41L-955		rpw3@sgi.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