Newsgroups: comp.lang.clos
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!newsserver.jvnc.net!adl33cc!sbloch
From: sbloch@adl15.adelphi.edu (Stephen Bloch)
Subject: Re: interning puzzle in packages
Message-ID: <D49w5r.94z@adl33cc.adelphi.edu>
Sender: news@adl33cc.adelphi.edu (USENET News System)
Nntp-Posting-Host: adl15.adelphi.edu
Organization: Adelphi University, Garden City, NY
References: <D49GI1.LCv@adl33cc.adelphi.edu>
Date: Mon, 20 Feb 1995 00:32:15 GMT
Lines: 47

I wrote:
>Is there any way to do this without either (a) dropping the package or
>(b) doing my own string-parsing from (read-line)?  Not that the latter
>would be so horrible, but I don't think it should be necessary.  I'd
>particularly like an easy-to-explain solution (dare I ask, one that
>allows me to avoid the whole issue of interning?) so I can show it to
>my beginning Lisp students.

I've found a workable solution: read the command in as a symbol, then
convert it back to a string before searching for it in an alist (keyed
by strings) with :test #'string= .  But just as I figured this out, the
same problem sneaked up and bit me from behind:

As nearly as I can tell, you can't define two methods for the same
generic in two different packages, and use both; if you do, use-package
complains about a name conflict and asks which name you want when you
really want both of them.

(in-package 'A)
...
(export 'name)
(defclass A-thing ...)
(defmethod name ((x A-thing)) ...)
=====================================
(in-package 'B)
...
(export 'name)
(defclass B-thing ...)
(defmethod name ((x B-thing)) ...)
=====================================
(in-package 'C)
(use-package '(A B))
...
(name this-A-thing)
...
(name this-B-thing)

Run-time polymorphism meets packaging and loses.  Surely people do this
kind of thing often.  Is there a nice way around this, that I just
haven't figured out yet?

(BTW, I'm working in CLISP.)
--
                                                 Stephen Bloch
                                           sbloch@boethius.adelphi.edu
                                          (or sbloch@adl15.adelphi.edu)
                                        Math/CS Dept, Adelphi University
