ram-ashwin@YALE.ARPA (Ashwin Ram) (08/20/87)
It would be nice to have a LOAD variant that loaded a file only if it was not already loaded. E.g., if you use a particular sub-system or package in two different places, you don't want it reloaded. REQUIRE is pretty close, but it checks features rather than loaded files, and most people don't include PROVIDE forms in their packages (including many files in the standard Emacs distribution. E.g., you can't do this with MAILALIAS since it is a file that is autoloaded by name rather than by a required feature.) Since many functions are autoloaded by filename rather than by requiring/providing a feature, it makes sense to have a MAYBE-LOAD or REQUIRE-FILE or something (or perhaps a RELOAD-P argument to LOAD). Or maybe AUTOLOAD should be redesigned to be feature-oriented instead of file-oriented (E.g., (autoload function feature &optional file) to autoload "function", you need to require "feature" (which you get from "file")). Or maybe a AUTOLOAD-FEATURE. Or something. -- Ashwin. ARPA: Ram-Ashwin@cs.yale.edu UUCP: {decvax,linus,seismo}!yale!Ram-Ashwin BITNET: Ram@yalecs
ram-ashwin@YALE.ARPA (Ashwin Ram) (08/20/87)
You're right, I didn't state my point clearly. What I was trying to get at was this. Suppose my "wonderful-function" used a set of other wonderful functions that were part of a package. For example, suppose I wrote an rmail-like package that used a bunch of rmail functions, plus defined some new ones. Now, it would be nice if my package could just require the original rmail file, rather than autoloading each of these functions from that rmail file. If the rmail file doesn't provide a feature (I know rmail does, but many files don't), this is hard to do. You can either autoload each individual function you need (a pain), or you have to load the file (and have it reloaded again if you need this file for another package too). One simple solution would be to make each file automatically provide the name of the file itself as one of the features it provides (in addition to explicit provides in the file). Then you can easily require the file using existing require/provide mechanisms (which by the way I think are really neat). A related point: I think: (if (not (fboundp 'wonderful-function)) (require "wonderful-feature")) ; with optional wonderful-file is a cleaner way to do autoloads than: (if (not (fboundp 'wonderful-function)) (load "wonderful-file")) Since require's filename defaults to the feature name, the former is strictly more powerful than the latter. This gives you a way to do package dependencies in a slightly nicer way than autoload does. -- Ashwin. ARPA: Ram-Ashwin@cs.yale.edu UUCP: {decvax,linus,seismo}!yale!Ram-Ashwin BITNET: Ram@yalecs