Lisp HUG Maillist Archive

Name conflict with symbol from package COMMON-LISP

Hi, all!

We encountered an interesting problem concerning the naming of
functions. We have here quite a large collection of software based on a
specific Lisp-framework that has been developed using Macintosh Lisp. 
We are currently porting this framework to Lispworks 4.2.7 (Linux).

In principle, it works quite well apart from some 'interesting'
discoveries every now and then. But here is a problem we can't find a
solution for:

In this framework, there is a function called optimize defined in a
package called math (it gets exported, as well). When evaluating this
package, we get a warning stating:

Defining function OPTIMIZE visible from package COMMON-LISP.

That's ok, so far, naming conflicts happen all the time ;). 
We could, of course, just rename the function, but as it is part of the
framework which gets used in a lot of software this is annoying and
probably will lead to quite a lot of errors.

First, we tried not to export the symbol, but that's no help. So, we
tried to get rid of the symbol 'optimize; the problem is that the symbol
is rather persisting.
We found a symbol of that name in package KEYWORD (and in that package
only), so we tried the following; nothing of which worked:

1. Try: (unuse-package (find-package "KEYWORD"))

2. Try: (in-package :common-lisp)
        (unuse-package (find-package "KEYWORD"))

3.: (makunbound 'keyword::optimize)

4.: (unintern 'optimize (find-package "KEYWORD")

(This seems to be case-insensitive, we tried both optimize and OPTIMIZE)


Does anyone of you know a way how we can keep our function optimize
(with that name, that is) without making the Lisp useless? And shouldn't
at least one of the things we tried "remove" the symbol 'optimize?

Thanks,

Kai-Florian

-- 
---------------------------------------------------------------------
Dipl.-Inform. Kai-Florian Richter    richter@informatik.uni-bremen.de
AG COSY
FB 3  Mathematik & Informatik        phone: +49-421-218-9043
Universitaet Bremen                  fax:   +49-421-218-8620

www.informatik.uni-bremen.de/~richter
www.cosy.informatik.uni-bremen.de
---------------------------------------------------------------------


Re: Name conflict with symbol from package COMMON-LISP

Kai-Florian Richter <richter@informatik.uni-bremen.de> writes:

> Does anyone of you know a way how we can keep our function optimize
> (with that name, that is) without making the Lisp useless? And shouldn't
> at least one of the things we tried "remove" the symbol 'optimize?

Personally, I would have avoided using 'optimize, but anyway, here's
one way to do it:

CAPI-E 32 > (defpackage foobar (:use :cl)(:shadow :optimize)(:export :optimize))
#<PACKAGE FOOBAR>

CAPI-E 34 > (describe 'cl:optimize)

OPTIMIZE is a SYMBOL
NAME          "OPTIMIZE"
VALUE         #<unbound value>
FUNCTION      #<unbound function>
PLIST         (PKG::SYMBOL-NAME-STRING "OPTIMIZE" SYSTEM::DECLARATION-P T)
PACKAGE       #<PACKAGE COMMON-LISP>

CAPI-E 35 > (describe 'foobar:optimize)

FOOBAR:OPTIMIZE is a SYMBOL
NAME          "OPTIMIZE"
VALUE         #<unbound value>
FUNCTION      #<unbound function>
PLIST         NIL
PACKAGE       #<PACKAGE FOOBAR>

The drawback of this is of course that you must write '(cl:optimize ...) 
in your declare forms whenever you're in a package that is or uses the 
foobar package.
-- 
  (espen)


Re: Name conflict with symbol from package COMMON-LISP

On Wednesday 05 March 2003 08:58 am, Kai-Florian Richter wrote:
> Defining function OPTIMIZE visible from package COMMON-LISP.

I never get this stuff correct, but it won't stop me from guessing :-).  

Isn't the problem that your Math package (or the framework) :use's 
COMMON-LISP? 

If you can't prevent MATH from :use'ing COMMON-LISP, then maybe this is where 
:shadow and :shadowing-import would be useful?

pt



Re: Name conflict with symbol from package COMMON-LISP

Am Mit, 2003-03-05 um 15.18 schrieb Espen Vestre:

> Personally, I would have avoided using 'optimize, but anyway, here's
> one way to do it:
I also think that the name is not really clever. But it wasn't my idea
and it obviously works fine on a Mac. 

> CAPI-E 32 > (defpackage foobar (:use :cl)(:shadow :optimize)(:export :optimize))
> #<PACKAGE FOOBAR>
> 
> CAPI-E 34 > (describe 'cl:optimize)
> 
> OPTIMIZE is a SYMBOL
> NAME          "OPTIMIZE"
> VALUE         #<unbound value>
> FUNCTION      #<unbound function>
> PLIST         (PKG::SYMBOL-NAME-STRING "OPTIMIZE" SYSTEM::DECLARATION-P T)
> PACKAGE       #<PACKAGE COMMON-LISP>
> 
That does it. Even though I thought I already tested this one. I must
have done something wrong back then :( 
Thanks a lot!

> The drawback of this is of course that you must write '(cl:optimize ...) 
> in your declare forms whenever you're in a package that is or uses the 
> foobar package.
That seems to be ok. I doubt that we will use cl:optimize much (What
does it anyway?).

Again, thanks a lot!

Kai-Florian

-- 
---------------------------------------------------------------------
Dipl.-Inform. Kai-Florian Richter    richter@informatik.uni-bremen.de
AG COSY
FB 3  Mathematik & Informatik        phone: +49-421-218-9043
Universitaet Bremen                  fax:   +49-421-218-8620

www.informatik.uni-bremen.de/~richter
www.cosy.informatik.uni-bremen.de
---------------------------------------------------------------------


Re: Name conflict with symbol from package COMMON-LISP

Kai-Florian Richter <richter@informatik.uni-bremen.de> writes:

> That seems to be ok. I doubt that we will use cl:optimize much (What
> does it anyway?).

You use it in declaration forms to state your optimization preferences.

-- 
  (espen)


Updated at: 2020-12-10 09:00 UTC