From: Pierre R. Mai
Subject: Re: load implementations
Date: 
Message-ID: <87ellrp2o0.fsf@orion.bln.pmsf.de>
Myriam Abramson <········@osf1.gmu.edu> writes:

> Hi!
> 
> How do I indicate to the load function to compile the file if
> necessary? Very useful feature ... 
> 
> (a) in allegro
> (b) in clisp
> (c) in cmucl

The following should portably work on any ANSI CL implementation, for
filesystems that record a useful file modification/creation time:

(defun load-compiled (pathname)
  "Compile pathname, if necessary, and load the compiled file."
  (unless (probe-file pathname)
    (error "The source file ~A doesn't exist!" pathname))
  (let ((compiled-pathname (compile-file-pathname pathname)))
    (unless (and (probe-file compiled-pathname)
                 (< (file-write-date pathname) 
                    (file-write-date compiled-pathname)))
      (compile-file pathname))
    (unless (probe-file compiled-pathname)
      (cerror "Load source file ~A instead."
              "Compilation of ~A didn't yield a compiled file named ~A"
              pathname compiled-pathname)
      (setq compiled-pathname pathname))
    (load compiled-pathname)))

That said, most IDEs will offer similar functionality in a better
integrated form, allowing you to compile (and load) the current
file/buffer in the editor, etc.

Regs, Pierre.

-- 
Pierre R. Mai <····@acm.org>                    http://www.pmsf.de/pmai/
 The most likely way for the world to be destroyed, most experts agree,
 is by accident. That's where we come in; we're computer professionals.
 We cause accidents.                           -- Nathaniel Borenstein