[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
disassemble and compile questions
Date: Wed, 25 Sep 85 16:35:06 pdt
From: Bob Shaw <bs%hplabs.csnet@CSNET-RELAY.ARPA>
I'm in need of enlightenment. The answers to the following two
questions are not obvious from my readings of the book.
I think you've come up with some good places where the book would
benefit from more precise language.
1. If f is an interpreted function, does (disassemble 'f)
cause f to become a compiled function?
That seems like a bad idea (as you say below).
2. What is the appropriate way to compile a function object
that is not compiled, not a lambda-expression and not the
function definition for a symbol? Consider the "lexical
closure" example in section 2.13 of CLtL.
The only kind of uncompiled function object that exists is the lambda
More on 1:
According to CLtl section 25.1, in the definition of disassemble,
"The argument should be either a function object, a lambda-expression,
or a symbol with a function definition. If the relevent function is
not a compiled function, it is first compiled. ... This is primarily
useful for debugging the compiler ... ."
Side-effecting the function cell by disassembling does not seem like
a result I would desire, especially when debugging the compiler.
Is (compile 'symbol) or (compile nil (symbol-function 'symbol)) the
intended means of compilation?
In Symbolics' implementation, disassemble will compile a lambda
expression, but if given a symbol whose function definition is
interpreted, it will complain rather than compile it. This seems
consistent with the statement that the feature of disassemble compiling
interpreted things is for debugging the compiler.
More on 2:
The definition of compile states that it will only handle lambda-
expressions: "If definition is supplied, it should be a lambda-expression,
the interpreted function to be compiled. If it is not supplied, then
name should be a symbol with a definition that is a lambda-expression;
... ." Section 2.13 states that lists other than lambda expessions
may, in certain implementations, serve as functions. Should the
definition of compile include such cases? I hope so.
I don't think the language designers intended that you be able to compile
lexical closures. Note that it is possible to create two lexical closures
that have a binding in common; in order to compile one of these, leave the
other interpreted, and obtain correct semantics, the compiler would have
to use the same representation of lexical variable binding environments
as the interpreter. Also note that the argument to COMPILE is specified
as a lambda-expression, not as a function in the general sense of section 2.13.