Subject: [clisp-list] Package question (possible bug?)

From: Nathan Froyd <[email-masked]>
Date: Tue, 28 Nov 2000 23:24:06 -0500

I am still experimenting with the `trees' pacakge from CMU as well as
Franz's free `htmlgen.cl' and had some questions resolving packages and
the read-eval-print loop.

In `htmlgen.cl', the DEFPACKAGE form looks like:

(defpackage :net.html.generator
  (:export #:html 
	   #:html-print
	   #:html-print-list
	   #:html-stream 
	   #:*html-stream*))

which is pretty understandable.  In the `rbtrees-package.lisp' file from
the `trees' pacakge, the DEFPACKAGE looks like:

(defpackage "RED-BLACK-TREES" (:use "COMMON-LISP" "TREES")
  (:nicknames "RB-TREES" "RBT")
  (:export make-red-black-tree
	   tree-p
	   size
	   element-type
	   name
	   empty-p
	   search
	   insert
	   traverse
	   minimum
	   maximum
	   successor
	   predecessor
	   delete-by-key
	   select
	   element-rank
	   empty-error
	   duplicate-key
	   version)
  (:shadow make-tree
	   tree-p
	   name
	   empty-p
	   insert
	   delete-by-key
	   empty-error
	   version)
  (:shadowing-import-from "TREES" search))

(slightly cleaned up).  `binary-trees-package.lisp' contains:

(defpackage "TREES" (:use "COMMON-LISP")
  (:export make-tree
	   tree-p
	   size
	   element-type
	   name
	   empty-p
	   search
	   insert
	   traverse
	   minimum
	   maximum
	   successor
	   predecessor
	   delete-by-key
	   empty-error
	   duplicate-key)
  (:shadow search))

My questions are as follows:

1) In the repl, I can type

(use-package :net.<TAB>

and get the proper completion (after loading the file, of course).
Whereas with the other form, I type

(use-package :red-<TAB>

and get nothing.  Why the difference?

2) When loading the appropriate files and typing the following:

(use-package :trees)

I get a name conflict with the symbol SEARCH.  Why is this?  Doesn't the
DEFPACKAGE specify that TREES::SEARCH overrides SEARCH in the current
package?  The same symptoms occur with:

(use-package :rbt)

only with more symbols.  Does :SHADOW not work?

3) Not really a CLISP question; more a package question.  What does the
(:USE "COMMON-LISP") declaration do?  `htmlgen.cl' doesn't use it and it
works fine.

This is with CLISP 2000-03-09 (clisp --version), although the source
tarball untarred into the directory clisp-2000-09-02.

As a side note, is the nightly snapshot site
(ftp://cellar.goems.com/pub/clisp/) down?  I can't seem to access it.

Thanks for all the help!
-- 
</nathan>  [email-masked]  |  http://www.rose-hulman.edu/~froydnj/

Yes, God had a deadline.  So He wrote it all in Lisp.

---

From: Sam Steingold <[email-masked]>
Date: 29 Nov 2000 11:01:20 -0500

> * In message <[email-masked]>
> * On the subject of "[clisp-list] Package question (possible bug?)"
> * Sent on Tue, 28 Nov 2000 23:24:06 -0500
> * Honorable Nathan Froyd <[email-masked]> writes:
>

you might have more than 1 package starting with "red-".
what happens when you hit TAB twice?
(this is the same behavior as with bash - both use readline)

> only with more symbols.  Does :SHADOW not work?

use `shadowing-import'.

`search' comes to TREES from COMMON-LISP.
I will leave the details to comp.lang.lisp or Bruno, if he has time, but
I suggest that you read CLHS on `defpackage', `shadow' and
`package-shadowing-symbols'. 

> (:USE "COMMON-LISP") declaration do?  `htmlgen.cl' doesn't use it and it

in most lisps, COMMON-LISP and LISP are the same, but in CLISP they are
different (COMMON-LISP is for ANSI, LISP - for CLtL1), although, I hope,
not for long.

> tarball untarred into the directory clisp-2000-09-02.

this is _strange_.  where did you get the tarball?!

> (ftp://cellar.goems.com/pub/clisp/) down?  I can't seem to access it.

yes, it is dead, and, probably, for good.

I am investigating my options.
If you have a linux box and can give me ssh access to it, it would be
greatly appreciated...

-- 
Sam Steingold (http://www.podval.org/~sds)
Support Israel's right to defend herself! <http://www.i-charity.com/go/israel>
Microsoft: announce yesterday, code today, think tomorrow.

---

From: Nathan Froyd <[email-masked]>
Date: Wed, 29 Nov 2000 13:13:33 -0500

> (this is the same behavior as with bash - both use readline)

I don't have multiple packages that start with "red-".  Nothing happens
after hitting TAB twice.

> `package-shadowing-symbols'. 

Ugh. :)  It would seem to me that :SHADOW would do what you seem to
indicate :SHADOWING-IMPORT does... (I haven't read the CLHS yet)

> different (COMMON-LISP is for ANSI, LISP - for CLtL1), although, I hope,

But why the difference?  I think the `trees' package horks if the (:USE
"COMMON-LISP") is not present.  Not sure, though.

> this is _strange_.  where did you get the tarball?!

From the nightly snapshot site.  Tarball clisp-2000-09-02.tgz.

> If you have a linux box and can give me ssh access to it, it would be

I do, but I'm not sure if the connection speed would be up to snuff...
-- 
</nathan>  [email-masked]  |  http://www.rose-hulman.edu/~froydnj/

---

From: Bruno Haible <[email-masked]>
Date: Sat, 2 Dec 2000 04:58:33 +0100 (CET)

Nathan Froyd writes:

> (defpackage :net.html.generator ...

> (defpackage "RED-BLACK-TREES" ...
> 

Because :red-<TAB> is asking for the completion of a keyword startting
with "RED-". The first defpackage form created an (otherwise useless)
keyword, the second form didn't.

> package?

The (:shadow search) in package TREES resolves the conflict for the
package TREES. The (:shadowing-import-from "TREES" search) resolves
the conflict for the package RED-BLACK-TREES. But you still get a
conflict in every other package that wants to use-package TREES.

One way to resolve this is something like

    (defmacro trees:use-trees-package ()
      `(progn
         (shadowing-import 'trees:search *package*)
         (use-package #:trees *package*)))

and then use

     (trees:use-trees-package)

instead of

     (use-package :trees)

> (:USE "COMMON-LISP") declaration do?

It requests CLtL2/ANSI CL semantics from the implementation. If you
don't write it, some implementations (like CLISP) use "LISP" and thus
offer CLtL1 semantics where CLtL1 and CLtL2 differ.

Bruno