[Ecls-list] symbol-macro usage
Alexander Gavrilov
angavrilov at gmail.com
Sat Feb 13 08:01:57 UTC 2010
Hi,
Could you also comment on the troubles that happen over here?
http://dwim.hu/darcsweb/darcsweb.cgi?r=HEAD%20hu.dwim.def;a=headblob;f=/integration/common.lisp
Namely (and in case the above link is temporarily
unavailable), the original non-ecl code is as follows:
#-ecl
(eval-when (:compile-toplevel :load-toplevel :execute)
(unintern 'common-lisp:in-package :hu.dwim.common)
(shadow "IN-PACKAGE" :hu.dwim.common))
#-ecl
(eval-when (:compile-toplevel :load-toplevel :execute)
;; this export is not inside the above eval-when for a reason.
(export 'hu.dwim.common::in-package :hu.dwim.common)
(assert (not (eq 'hu.dwim.common::in-package 'common-lisp:in-package))))
#-ecl
(def macro hu.dwim.common::in-package (package-name)
...)
When one tries to use it with ECL, the compiling part seems
to work as expected, and the symbol is recorded in the fasl
as hu.dwim.common::in-package. However, when it is loaded,
the references are resolved before any code is executed,
so the assertion fails - and if it is removed, the macro
definition overwrites the original common-lisp macro with
disastrous consequences.
Alexander
> The error is very subtle. You have to go here
> http://www.lispworks.com/documentation/HyperSpec/Body/03_bcaa.htm
>
> define-symbol-macro does not have compile-time side effects. That means that
> when the compiler reaches the form (defvar a m) it does not know that M is a
> macro! This causes a load time error because the code is designed to find
> out the value of the variable "M", not to use "tstst".
More information about the ecl-devel
mailing list