From: zoav1602
Subject: SLIME C-c C-k causes name-conflicts
Date: 
Message-ID: <355dadcb-5cd1-4286-8cef-105922c6ef32@l8g2000vbp.googlegroups.com>
Hello,
I have this problem: I visit a file defining a package in emacs slime,
compile and load it with C-c C-k, then switch to the REPL, and do (use-
package ...) and get a condition sb-int:name-conflict. (emacs 22.1.1,
slime 3.0-alpha, sbcl 1.0.6). I believe my lisp file complies with
lisp standards, so give me a hint!

Here is the lisp file I load


(defpackage #:seidel-sparse
  (:use :cl)
  (:export
   *eps*
   #:seidel-sparse))

(in-package #:seidel-sparse)

(defvar *eps* 5d-6)

(defun seidel-sparse(A b x)
  (declare ;(type (simple-array double-float (*)) b x)
	   ;(type (array list (*)) A)
	   (special *eps*))
  "Seidel algorithm for sparse matrices. Solves x=Ax+b for x.
   A[i] = ( (i . aii) . rest )"
  (labels ((seidel1 ()
	     (let ((tmp 0d0)
		   (accur 0d0)
		   (aii 0d0)
		   (n (array-dimension x 0)))
	       (dotimes (i n accur)
		 (setq tmp 0d0
		       aii (/ (- 1d0 (cdar (aref A i)))))
		 (dolist (aij (rest (aref A i)))
		   (incf tmp (* (cdr aij) (aref x (car aij)) aii)))
		 (incf tmp (* (aref b i) aii))
		 (setq accur (max accur (abs (- tmp (aref x i)))))
		 (setf (aref x i) tmp)))))
    (do ((iter 0 (+ 1 iter))
	 (accur (seidel1) (seidel1)))
	((or (> iter 50)
	     (< accur *eps*))))))

Here is what I get:

USE-PACKAGE #<PACKAGE "SEIDEL-SPARSE"> causes name-conflicts in
#<PACKAGE "COMMON-LISP-USER"> between the following symbols:
  SEIDEL-SPARSE:*EPS*, COMMON-LISP-USER::*EPS*
   [Condition of type SB-INT:NAME-CONFLICT]
See also:
  Common Lisp Hyperspec, 11.1.1.2.5 [:section]

From: Rainer Joswig
Subject: Re: SLIME C-c C-k causes name-conflicts
Date: 
Message-ID: <8db57183-1420-442f-840a-5a555dbaa291@n30g2000vba.googlegroups.com>
On 18 Jun., 08:14, zoav1602 <········@gmail.com> wrote:
> Hello,
> I have this problem: I visit a file defining a package in emacs slime,
> compile and load it with C-c C-k, then switch to the REPL, and do (use-
> package ...) and get a condition sb-int:name-conflict. (emacs 22.1.1,
> slime 3.0-alpha, sbcl 1.0.6). I believe my lisp file complies with
> lisp standards, so give me a hint!
>
> Here is the lisp file I load
>
> (defpackage #:seidel-sparse
>   (:use :cl)
>   (:export
>    *eps*
>    #:seidel-sparse))
>
> (in-package #:seidel-sparse)
>
> (defvar *eps* 5d-6)
>
> (defun seidel-sparse(A b x)
>   (declare ;(type (simple-array double-float (*)) b x)
>            ;(type (array list (*)) A)
>            (special *eps*))
>   "Seidel algorithm for sparse matrices. Solves x=Ax+b for x.
>    A[i] = ( (i . aii) . rest )"
>   (labels ((seidel1 ()
>              (let ((tmp 0d0)
>                    (accur 0d0)
>                    (aii 0d0)
>                    (n (array-dimension x 0)))
>                (dotimes (i n accur)
>                  (setq tmp 0d0
>                        aii (/ (- 1d0 (cdar (aref A i)))))
>                  (dolist (aij (rest (aref A i)))
>                    (incf tmp (* (cdr aij) (aref x (car aij)) aii)))
>                  (incf tmp (* (aref b i) aii))
>                  (setq accur (max accur (abs (- tmp (aref x i)))))
>                  (setf (aref x i) tmp)))))
>     (do ((iter 0 (+ 1 iter))
>          (accur (seidel1) (seidel1)))
>         ((or (> iter 50)
>              (< accur *eps*))))))
>
> Here is what I get:
>
> USE-PACKAGE #<PACKAGE "SEIDEL-SPARSE"> causes name-conflicts in
> #<PACKAGE "COMMON-LISP-USER"> between the following symbols:
>   SEIDEL-SPARSE:*EPS*, COMMON-LISP-USER::*EPS*
>    [Condition of type SB-INT:NAME-CONFLICT]
> See also:
>   Common Lisp Hyperspec, 11.1.1.2.5 [:section]

You should escape the *EPS* symbol in the DEFPACKAGE form. Otherwise
it may create something like cl-user::*eps*
depending which package is *package* when you read the defpackage
form.

Use one of these

  "*EPS*"
  :*EPS*
  #:*EPS*

Where I prefer to use strings for all symbol names in DEFPACKAGE,
since it avoids the creation of possibly unwanted symbols.
From: zoav1602
Subject: Re: SLIME C-c C-k causes name-conflicts
Date: 
Message-ID: <4fc3b401-b5d8-45e0-b7dd-e9fa4976ba09@o30g2000vbc.googlegroups.com>
On 18 ÉÀÎ, 11:29, Rainer Joswig <······@lisp.de> wrote:
Nope, this doesn't help. I have the problem even when I load the files
using asdf and then type use-package.
> Use one of these
>
> š "*EPS*"
> š :*EPS*
> š #:*EPS*
>
> Where I prefer to use strings for all symbol names in DEFPACKAGE,
> since it avoids the creation of possibly unwanted symbols.
From: Rainer Joswig
Subject: Re: SLIME C-c C-k causes name-conflicts
Date: 
Message-ID: <730ea2f7-5b4b-430f-b15c-aed7a130c5b8@f10g2000vbf.googlegroups.com>
On 18 Jun., 09:44, zoav1602 <········@gmail.com> wrote:
> On 18 ÉÀÎ, 11:29, Rainer Joswig <······@lisp.de> wrote:
> Nope, this doesn't help. I have the problem even when I load the files
> using asdf and then type use-package.

Sure, it has nothing to do with loading, asdf, ...

It is a package problem, read the error.

>
>
>
> > Use one of these
>
> > š "*EPS*"
> > š :*EPS*
> > š #:*EPS*
>
> > Where I prefer to use strings for all symbol names in DEFPACKAGE,
> > since it avoids the creation of possibly unwanted symbols.

Sure it helps.


What does (FIND-SYBMOL "*EPS*" "CL-USER")  return?

If there is a symbol cl-user::*eps*  you need to find out where it is
coming from.
The first guess it is coming from your DEFPACKAGE form.
It might additionally already be present in CL-USER from somewhere
else.

If CL-USER has an *EPS* symbol and you USE your package, which also
exports a symbol
with *EPS* as its name then you get a name clash.

possible actions then:

* why is there *eps* in CL-USER? possibly get rid of it, especially if
it is accidentally introduced
* shadow the cl-user::*eps*
* change the export list of your package


(defpackage #:seidel-sparse
  (:use :cl)
  (:export
   "*EPS*"
   #:seidel-sparse))
From: Pascal J. Bourguignon
Subject: Re: SLIME C-c C-k causes name-conflicts
Date: 
Message-ID: <87my86ez7w.fsf@galatea.local>
Rainer Joswig <······@lisp.de> writes:
> If CL-USER has an *EPS* symbol and you USE your package, which also
> exports a symbol
> with *EPS* as its name then you get a name clash.
>
> possible actions then:
>
> * why is there *eps* in CL-USER? possibly get rid of it, especially if
>   it is accidentally introduced
> * shadow the cl-user::*eps*
> * change the export list of your package
    and then either shadow cl-user::*eps* before reloading the package
    file and re-using it, or quit and reload everything to reset
    cl-user.

  * do not use cl-user.
      (defpackage "SEIDEL-SPARSE-USER"
         (:nicknames "SSU")
         (:use "CL" "SEIDEL-SPARSE"))
      (in-package "SSU") ; instead of "CL-USER"
      

-- 
__Pascal Bourguignon__
From: zoav1602
Subject: Re: SLIME C-c C-k causes name-conflicts
Date: 
Message-ID: <5bb3ab71-9ae4-44fc-b5a9-eb56fc078247@n8g2000vbb.googlegroups.com>
When I do all the same things in plain sbcl running in terminal
everything works fine!
When I run a new slime session, find-symbol returns nil for both
"*EPS*" and "SEIDEL-SPARSE", so I load the file into lisp and get this
name-conflict. After changing *eps* into "*EPS*" this complain
disappeared, now Im' facing name-conflict with sparse-seidel. Changing
it to "SPARSE-SEIDEL" doesn't help either. So I think something goes
wrong inside slime+emacs


On 18 ÉÀÎ, 12:13, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> Rainer Joswig <······@lisp.de> writes:
> > If CL-USER has an *EPS* symbol and you USE your package, which also
> > exports a symbol
> > with *EPS* as its name then you get a name clash.
>
> > possible actions then:
>
> > * why is there *eps* in CL-USER? possibly get rid of it, especially if
> > š it is accidentally introduced
> > * shadow the cl-user::*eps*
> > * change the export list of your package
>
> š š and then either shadow cl-user::*eps* before reloading the package
> š š file and re-using it, or quit and reload everything to reset
> š š cl-user.
>
> š * do not use cl-user.
> š š š (defpackage "SEIDEL-SPARSE-USER"
> š š š š š(:nicknames "SSU")
> š š š š š(:use "CL" "SEIDEL-SPARSE"))
> š š š (in-package "SSU") ; instead of "CL-USER"
>
> --
> __Pascal Bourguignon__
From: Rainer Joswig
Subject: Re: SLIME C-c C-k causes name-conflicts
Date: 
Message-ID: <0923b32f-07c1-446b-86e1-54160e31059d@p4g2000vba.googlegroups.com>
On 18 Jun., 10:24, zoav1602 <········@gmail.com> wrote:
> When I do all the same things in plain sbcl running in terminal
> everything works fine!

 Your original code shows the error in a simple terminal session with
SBCL:

RJMBP:~ joswig$ sbcl
This is SBCL 1.0.22, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (defpackage #:seidel-sparse
  (:use :cl)
  (:export
   *eps*
   #:seidel-sparse))

#<PACKAGE "SEIDEL-SPARSE">
* (use-package "SEIDEL-SPARSE")

debugger invoked on a NAME-CONFLICT:
  USE-PACKAGE #<PACKAGE "SEIDEL-SPARSE"> causes name-conflicts in
  #<PACKAGE "COMMON-LISP-USER"> between the following symbols:
    SEIDEL-SPARSE:*EPS*, COMMON-LISP-USER::*EPS*
See also:
  The ANSI Standard, Section 11.1.1.2.5

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RESOLVE-CONFLICT] Resolve conflict.
  1: [ABORT           ] Exit debugger, returning to top level.

(NAME-CONFLICT
 #<PACKAGE "COMMON-LISP-USER">
 USE-PACKAGE
 #<PACKAGE "SEIDEL-SPARSE">)[:EXTERNAL]
0]

This goes away when you use "*EPS*" in defpackage (remember, symbols
have uppercase
names internally by default) - as mentioned before.

Also remember, Lisp reads forms with something like READ. READ already
creates the symbols during reading, if necessary - before the code is
compiled and executed.

> When I run a new slime session, find-symbol returns nil for both
> "*EPS*" and "SEIDEL-SPARSE", so I load the file into lisp and get this
> name-conflict. After changing *eps* into "*EPS*" this complain
> disappeared, now Im' facing name-conflict with sparse-seidel. Changing
> it to "SPARSE-SEIDEL" doesn't help either. So I think something goes
> wrong inside slime+emacs
>

You might want to post the error and how to reproduce it...