[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Questions to Bill's response
- Subject: Questions to Bill's response
- From: email@example.com (Bill St. Clair)
- Date: Thu, 3 Jun 1993 11:54:10 -0500
At 11:01 AM 6/3/93 -0400, Jiqian Pan wrote:
>Regarding Bill's response to my problem in compilation, I wonder
>whether it is necessary to use DEF-LOAD-POINTERS if I use DEFVAR
>or DEFPARAMETER to define a variable with the type MACPTR
>(e.g., records). What is the difference between a DEFVAR with
>DEF-LOAD-POINTERS and a DEFVAR without DEF-LOAD-POINTERS? Does
>the former define a constant? Thanks.
(defvar *test-rect* (make-record :rect ...))
This form will create a record when you load the file containing it.
If, however, you save this world with save-application, after
starting up the saved application, the value of *test-rect* will
be #<dead-macptr ...>, since save-application has no way of knowing
how to save or restore objects allocated in the Mac Heap.
(def-load-pointers *test-rect* ()
(setq *test-rect* (make-record :rect ...)))
These forms have the same result as the single DEFVAR above when you
load the file for the first time. When loading a saved-application,
however, the DEF-LOAD-POINTERS provides code to be run at startup
time to initialize *test-rect*.
This points out one big advantage of Lisp over C & Pascal.
Lisp objects know their types. C & Pascal objects are just pointers to
memory. Only the compiler knows how to interpret the bits in that memory.