[EMAIL PROTECTED] writes:

> There's a problem when i define a class with name "method" in a new package. 

By default, each package uses the COMMON-LISP package.  TOTO
inherits the METHOD symbol from there.

* (defpackage "TOTO")
#<The TOTO package, 0/9 internal, 0/2 external>

* (package-use-list "TOTO")
(#<The COMMON-LISP package, 1677/2369 internal, 978/1227 external>)

* (symbol-package 'toto::method)
#<The COMMON-LISP package, 1677/2369 internal, 978/1227 external>

* (eq 'toto::method 'common-lisp:method)
T

According to CLHS section 11.1.2.1.2, item 4, a conforming
program must not define such a symbol as the name of a class.
As COMMON-LISP:METHOD is already the name of an important
standard class, it's no wonder the Lisp system crashes.

One solution would be to override the default and specify that
the TOTO package does not use any other packages:

  (defpackage "TOTO"
    (:use))
  (in-package "TOTO")
  (cl:defclass method () ())

Note that you would then have to use e.g. cl:defclass rather
than plain defclass.  If this is too annoying, you can instead
keep using COMMON-LISP but shadow just the METHOD symbol:

  (defpackage "TOTO" 
    (:use "COMMON-LISP")
    (:shadow "METHOD"))
  (in-package "TOTO")
  (defclass method () ())

Alternatively, you could use nothing but import those symbols
you need:

  (defpackage "TOTO"
    (:use)
    (:import-from "COMMON-LISP" "IN-PACKAGE" "DEFCLASS"))
  (in-package "TOTO")
  (defclass method () ())

Which approach is best depends on how many symbols you need from
COMMON-LISP.

Reply via email to