[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Gcl-devel] defpackage non-compliant?
From: |
Mike Thomas |
Subject: |
RE: [Gcl-devel] defpackage non-compliant? |
Date: |
Wed, 9 Jul 2003 09:05:48 +1000 |
Hi Paul.
| BTW, I was using (eval-when (load eval compile) ...) in many places
| in ansi-tests to get it to work with gcl. If we get that working
| (more or less) I can convert all those to non-deprecated forms.
Yesterday I added the keywords :load-toplevel, :compile-toplevel and
:execute to CVS GCL in such a way that they mirror exactly the current
behaviour of load, compile and eval as arguments to eval-when. My
understanding is that there is more work needed to make eval-when work
correctly to the ANSI spec however, as :execute does not work.
For example, the snippet from the Hyperspec given at the end of this email
gives:
>(load "ewtest")
Loading ewtest.lsp
Finished loading ewtest.lsp
T
>(compile-file "ewtest")
Compiling ewtest.lsp.
FOO5
FOO6
End of Pass 1.
End of Pass 2.
OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
Finished compiling ewtest.
#p"ewtest.o"
>(load "ewtest.o")
Loading ewtest.o
start address -T 1020f624 Finished loading ewtest.o
96
>
Cheers
Mike Thomas.
;;; The EVAL-WHEN in this case is not at toplevel, so only the :EXECUTE
;;; keyword is considered. At compile time, this has no effect.
;;; At load time (if the LET is at toplevel), or at execution time
;;; (if the LET is embedded in some other form which does not execute
;;; until later) this sets (SYMBOL-FUNCTION 'FOO1) to a function which
;;; returns 1.
(let ((x 1))
(eval-when (:execute :load-toplevel :compile-toplevel)
(setf (symbol-function 'foo1) #'(lambda () x))))
;;; If this expression occurs at the toplevel of a file to be compiled,
;;; it has BOTH a compile time AND a load-time effect of setting
;;; (SYMBOL-FUNCTION 'FOO2) to a function which returns 2.
(eval-when (:execute :load-toplevel :compile-toplevel)
(let ((x 2))
(eval-when (:execute :load-toplevel :compile-toplevel)
(setf (symbol-function 'foo2) #'(lambda () x)))))
;;; If this expression occurs at the toplevel of a file to be compiled,
;;; it has BOTH a compile time AND a load-time effect of setting the
;;; function cell of FOO3 to a function which returns 3.
(eval-when (:execute :load-toplevel :compile-toplevel)
(setf (symbol-function 'foo3) #'(lambda () 3)))
;;; #4: This always does nothing. It simply returns NIL.
(eval-when (:compile-toplevel)
(eval-when (:compile-toplevel)
(print 'foo4)))
;;; If this form occurs at toplevel of a file to be compiled, FOO5 is
;;; printed at compile time. If this form occurs in a non-top-level
;;; position, nothing is printed at compile time. Regardless of context,
;;; nothing is ever printed at load time or execution time.
(eval-when (:compile-toplevel)
(eval-when (:execute)
(print 'foo5)))
;;; If this form occurs at toplevel of a file to be compiled, FOO6 is
;;; printed at compile time. If this form occurs in a non-top-level
;;; position, nothing is printed at compile time. Regardless of context,
;;; nothing is ever printed at load time or execution time.
(eval-when (:execute :load-toplevel)
(eval-when (:compile-toplevel)
(print 'foo6)))