[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multiple copies of functions

Consider DEFSTRUCT.  DEFSTRUCT creates functions like make-foo, foo-slot,
foo-p, etc., etc.
These are mandated to be functions, although they used to be created as
macros in earlier Lisps.  To retain efficiency, a compiler will probably
want to compile them as inline structure-accessors and the like, as if
they really were macros.  The only case where you really need the body
of a function sitting around for them is in references like #'foo-slot.
In that case, it probably makes sense for the compiler to generate code
for foo-slot iff there is a #'foo-slot reference.  Since these functions
are built by the expansion of DEFSTRUCT, rather than living in some
permanent place, and they may be created only when needed (even if not,
they still have to get created), it is possible for the compilation of
wholly separate pieces of code to need the "same" function (and you 
would agree that they are the "same", would you not?).  In such a case,
the function body referenced by #'foo-slot in one program may be at a
different virtual address from the function body referenced by another.
Maybe this wouldn't be sufficiently "same" for a number of reasons.
But I think that one could, if one put one's mind to it, come up with
some situation where there are two copies of the "same" function that
reside at different memory locations (invalidating EQ as a comparison),
yet for all intents and purposes are the "same" code.  
I'd be happy to drop this topic.  I think I've learned a lot about the
possible approaches to the problem, and I don't want to descend into
an operating-system-dependent mode.