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

Re: Error on package redefinition?



Mark Mueller <stoffel@cs.tu-berlin.de> writes:
> I have a package definition in my code, and if i loaded my
> code again, the package definitions caused error messages:
> 
> > (make-package 'test)
> #<PACKAGE TEST>
> > (make-package 'test)
>  
> ** - Continuable Error
> a package with name "TEST" already exists.
> If you continue (by typing 'continue'): You can input another name.
> 
> In my case i solved the problem by asking if a package
> exists with (find-package ...) before i defined it new:
> 
> (if (not (find-package 'control))
>     (MAKE-PACKAGE 'control))

This does not solve the problem, because if you _compile_ your code
twice within the same Lisp session, it will still break in CLISP,
and have no effect in some other Lisp implementations.

Replace

> (if (not (find-package 'control))
>     (MAKE-PACKAGE 'control))

by

  (in-package "CONTROL")

The IN-PACKAGE function/macro(*) is properly handled in all Common Lisp
implementation, whether interpreter or compiler.

(*) IN-PACKAGE is a function with special compiler treatment in CLtL1,
and a macro in ANSI CL.


Bruno Haible                                     email: <haible@ilog.fr>
Software Engineer                                phone: +33-1-49083585