[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Quick question about lexically scoped defun...
Date: Sun, 10 Jul 88 18:19 EDT
From: David L. Andre <DLA@JASPER.SCRC.Symbolics.COM>
[All hell breaking loose deleted.]
From a quick look at the source, it appears that the patch Hornig gave
you was incorrect. Try
(defun si:enclose-top-level-environment (lambda env name) env)
Sorry for the confusion. Charlie's on vacation at the moment, otherwise
I'm sure this would have been corrected a lot sooner.
Thanks, I tried that and it worked. One problem however, the function that is
defined inside the lexical scope is *NOT* compiled. This happens irrespective
of whether I use the above patch or whether I don't and answer Yes to the
question that the compiler asks.
For example, put the following code in a editor buffer:
(let ((x 0))
(defun foo ()
(break)
x))
Then do m-X Compile Buffer.
Then type (foo) and when you get into the debugger type a few c-P's and
you will see the evaluator. This seems to happen no matter whther I
wrap a (progn 'compile around the outer LET or the DEFUN. In fact,
if after you do a m-X Compile Buffer you then type (disassemble 'foo)
to a Lisp Listener, this is what you get:
Command: (disassemble #'foo)
For Function #:DUMMY-FUNCTION-FOR-DISASSEMBLE
(BREAK) breakpoint in program
While compiling X:
The variable X is unknown and has been declared SPECIAL
0 ENTRY: 0 REQUIRED, 0 OPTIONAL
1 CALL-0-IGNORE #'BREAK
2 PUSH-INDIRECT X
3 RETURN-STACK
#<DTP-COMPILED-FUNCTION #:DUMMY-FUNCTION-FOR-DISASSEMBLE 302134225>
Clearly, the disassembler is first trying to compile the function.
In fact, an error happens during that compilation because it doesn't
know about lexically free variables --- and thus produces incorrect
code.
Now try (compile 'foo):
Command: (compile 'foo)
Error: Cannot find LAMBDA expression for FOO
COMPILE
Arg 0 (SYS:FUNCTION-SPEC): FOO
--Defaulted args:--
Arg 1 (COMPILER:LAMBDA-EXP): NIL
s-A, q: Return to Lisp Top Level in Dynamic Lisp Listener 1
s-B: Restart process Dynamic Lisp Listener 1
This is clearly bogus. Well FOO is:
Command: #'foo
#<SYS:LEXICAL-CLOSURE (LAMBDA NIL # X) 64215441>
What can I do to get this to work properly, that is to compile FOO.
Jeff
-------