[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with eval-when/shadowing-import



Roger Kehr <kehr@iti.informatik.th-darmstadt.de> writes:

> I have encountered a small problem in conjunction with EVAL-WHEN and
> SHADOWING-IMPORT. The following source can be used to see what
> happens:
> 
> ---snip
> ...
> #+:TEST
> (shadowing-import 'language:data)
> 
> #-:TEST
> (eval-when (compile load eval)
>   (shadowing-import 'language:data))
> ...
> ---snap

Thanks for this easily reproducible test code. The issue is hairy:

* The form (shadowing-import 'language:data) is treated specially by
  CLtL1 compilers, but -- as you noted -- in order to avoid magic in
  the compilers, CLtL2 and ANSI CL decided that `shadowing-import'
  isn't magic any more.

  CLISP supports the old CLtL1 way of doing it.

* For the sake of these new compilers you wrap the form in a
  (eval-when (compile load eval) ...).

  CLISP, according to CLtL2's description of `eval-when', first evaluates
  the form and then emits code for it. However, by doing the shadowing-import,
  you changed the code that is emitted.

The code I propose is

  (progn
    (eval-when (load eval)
      (shadowing-import 'language:data)
    )
    (eval-when (compile)
      (shadowing-import 'language:data)
  ) )

This way, CLISP will first emit the code and then modify its package
structure.

                 Bruno