From: Donald H. Mitchell
Subject: Removing symbols and packages when producing runtime images
Date: 
Message-ID: <3353EC58.6CA1@smartproject.com>
This issue of what symbols and packages can be safely removed from a
runtime image comes up occassionally in my work, and I always feel less
than enlightened.  Perhaps someone here can enlighten me (I do
understand packages and symbols).

I assume that any symbol that I use as a constant (not defconstant but
the literal symbol) must be preserved. That is, given the following
silly example, I need to ensure that 'less, 'equal, and 'greater get
preserved.
(defun compare (n1 n2)
  (cond ((< n1 n2) 'less)
        ((> n1 n2) 'greater)
        (t 'equal)))

I further presume that there's absolutely *no* need to preserve symbols
whose only role is as function arguments or local variables (i.e.,
arglist elements, let vars, multiple-value-bind vars, etc.)

What about symbols used only as function names (e.g., 'compare above)?
Can I assume the compiler translates the function references to point to
the actual function code and not need the symbol?

What about symbols that have values declared via defvar? These seem to
need preservation because code cannot inline a pointer to the value and
to inline a pointer to a pointer wouldn't save anything significant.
-- 
Donald H. Mitchell, PhD, PMP    ··········@smartproject.com
Proactive Solutions, Inc.       http://home.earthlink.net/~smartproject
412.835.2410                    412.835.2411 (fax)
From: Barry Margolin
Subject: Re: Removing symbols and packages when producing runtime images
Date: 
Message-ID: <5j1ed2$38n@pasilla.bbnplanet.com>
In article <·············@smartproject.com>,
Donald H. Mitchell <··········@smartproject.com> wrote:
>What about symbols used only as function names (e.g., 'compare above)?
>Can I assume the compiler translates the function references to point to
>the actual function code and not need the symbol?

It depends on whether you have a "block compiler", which processes all the
source files into a single executable image.  If not, the symbols need to
be retained for linkage between callers in one file and callees in
another.

It also needs to retain the symbol for indirection if you allow files to be
reloaded in order to redefine functions.

>What about symbols that have values declared via defvar? These seem to
>need preservation because code cannot inline a pointer to the value and
>to inline a pointer to a pointer wouldn't save anything significant.

Well, it would save the space being used to hold the symbol's name.  If you
have a thousand global variables (probably not a good idea, but it happens)
and their names average 12 characters in length, that's 3KB being saved.
OK, not a big deal these days....

Also, if you make use of EVAL and allow user input to be used to generate
the code that's evaluated, you need to retain all global variable and
function names.
-- 
Barry Margolin
BBN Corporation, Cambridge, MA
······@bbnplanet.com
(BBN customers, call (800) 632-7638 option 1 for support)