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

Problems with eval-when/shadowing-import



	Hello out there,

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
(defpackage :language (:use :CL)
	    (:export data))

(defpackage :sgmls (:use :CL)
	    (:export data))

(defpackage :tree (:use :CL :sgmls))

(eval-when (compile load eval)
  (in-package :tree))

(eval-when (compile load eval) (describe 'data))

#+:TEST
(shadowing-import 'language:data)

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

(eval-when (compile load eval) (describe 'data))
---snap

Since I mostly try to write my code as ANSI as possible, I need to
wrap most of the package stuff into EVAL-WHEN.

The problem occurs of the above piece of code is compiled and then
loaded. The behaviour differs if the feature :TEST is present or not.
In case the feature is not present the EVAL-WHEN form is processed,
otherwise the non-ANSI form without EVAL-WHEN is used. See what
happens:

---
> clisp -q -c shadow-test.lsp 

Compiling file /export/vol1/kehr/src/stil/tree/shadow-test.lsp ...
Description of
DATA
This is the symbol DATA.
The symbol lies in #<PACKAGE SGMLS> and is accessible in the packages SGMLS, TREE.
Description of
DATA
This is the symbol DATA.
The symbol lies in #<PACKAGE LANGUAGE> and is accessible in the packages LANGUAGE, TREE.
[...]

> clisp -q -i shadow-test.fas

;; Loading file shadow-test.fas ...
Description of
DATA
This is the symbol DATA.
The symbol lies in #<PACKAGE SGMLS> and is accessible in the packages SGMLS, TREE.
Description of
DATA
This is the symbol DATA.
The symbol lies in #<PACKAGE SGMLS> and is accessible in the packages SGMLS, TREE.
;; Loading of file shadow-test.fas is finished.
---

Obviously the SHADOWING-IMPORT did not work as expected. The symbol
DATA is still in package :sgmls.

If we try the same example with feature :TEST set, the result is as
expected. 

---
> clisp -q -c shadow-test.lsp 

Compiling file /export/vol1/kehr/src/stil/tree/shadow-test.lsp ...
Description of
DATA
This is the symbol DATA.
The symbol lies in #<PACKAGE SGMLS> and is accessible in the packages SGMLS, TREE.
Description of
DATA
This is the symbol DATA.
The symbol lies in #<PACKAGE LANGUAGE> and is accessible in the packages LANGUAGE, TREE.

> clisp -q -i shadow-test.fas
;; Loading file shadow-test.fas ...
Description of
DATA
This is the symbol DATA.
The symbol lies in #<PACKAGE SGMLS> and is accessible in the packages SGMLS, TREE.
Description of
DATA
This is the symbol DATA.
The symbol lies in #<PACKAGE LANGUAGE> and is accessible in the packages LANGUAGE, TREE.
;; Loading of file shadow-test.fas is finished.
---

Symbol DATA is in package :language.

Any ideas what is wrong? CLISP or me?

Cheers,

  Roger

-- 
======================================================================
Roger Kehr			   kehr@iti.informatik.th-darmstadt.de
Computer Science Department          Technical University of Darmstadt