[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
reloading a required file
- To: email@example.com
- Subject: reloading a required file
- From: firstname.lastname@example.org (Bob Hall)
- Date: Mon, 16 Aug 93 08:58:19 EDT
- Cc: email@example.com
- In-reply-to: Paul Shannon's message of Mon, 16 Aug 1993 01:59:52 GMT <PSHANNON.93Aug15205952@iapetus.cv.nrao.edu>
From: firstname.lastname@example.org (Paul Shannon)
Date: Mon, 16 Aug 1993 01:59:52 GMT
I have an mcl program in two files: a main file, and a small one
that defines a function that returns a view containing dialog items.
After I tinker with the dialog items, I save the file, and re-evaluate
all of the main file.
I had hoped that the function call
would detect that rules-dialog-box.lisp had changed since last loaded,
but it seems not to. The only solution I can imagine at this point is
to quit from mcl, and start from scratch. There must be a better way.
You can easily implement a recompile-and-reload-if-necessary function
using the Common Lisp function FILE-WRITE-DATE to compare the time
the binary was written with the time the source file was written.
Many defsystems do something like this.
(DEFUN SIMPLE-RECOMPILE-AND-RELOAD-IF-OUT-OF-DATE (SRCFILE-NO-EXTENSION)
"Assumes you want the binary to be in the same directory with .fasl
extension. You can parameterize this if desired."
(LET* ((SRC (FORMAT NIL "~a.lisp" SRCFILE-NO-EXTENSION))
(BIN (FORMAT NIL "~a.fasl" SRCFILE-NO-EXTENSION))
(WHEN (AND (PROBE-FILE SRC)
(OR (NOT (PROBE-FILE BIN))
(NULL (SETQ SRCDATE (FILE-WRITE-DATE SRC)))
(NULL (SETQ BINDATE (FILE-WRITE-DATE BIN)))
(> SRCDATE BINDATE)))
(COMPILE-FILE SRC :OUTPUT-FILE BIN)
(LOAD BIN)))) ;;in a defsystem, you'd put the LOAD outside the WHEN.
You can even add your own require-like functionality by (e.g.) binding a flag
when your rules-dialog-box file is loaded, then adding a check in the
above function for whether the flag is boundp.
While there may be an MCL-native way to do this, the approach above is
portable across Common Lisps (assuming you parameterize correctly for
file naming conventions).