[Ecls-list] symbol-macro usage

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Fri Feb 12 21:35:19 UTC 2010


On Thu, Feb 11, 2010 at 11:42 AM, Marko Kocić <marko.kocic at gmail.com> wrote:

> Actually what I was complaining is that when you load fas file
> symbol-macro is unbound.  Loading lisp file is ok. It deosn't have to
> do with the load-time-values like in hunchentoot examble.
>
> markko at mst:~$ cat bug.lisp
> (define-symbol-macro m "tstst")
> (defvar a m)
>

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".



>
> markko at mst:~$ ecl -norc -compile bug.lisp
> ;;; Loading #P"/home/markko/lib/ecl-10.2.1/cmp.fas"
> ;;; Loading #P"/home/markko/lib/ecl-10.2.1/sysfun.lsp"
> ;;; Compiling bug.lisp.
> ;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0
> ;;; Compiling (DEFVAR A ...).
> ;;; Variable M was undefined. Compiler assumes it is a global.


See what I mean? The compiler does not interpret M as a symbol macro.

The code above is non-conformant.

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100212/59fb7fa9/attachment.html>


More information about the ecl-devel mailing list