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

Re: Package problem, revisted

>   From: robin@jarrett.den.mmc.com (Robin Kladke (303-977-9760))


There are several things to point out here.

>   I tried Craig Lanning's suggestion and defined my
>   alp-clos package as:
>   (defpackage alp-clos) within the FCL-USER package.

If you are using ANSI-Common-Lisp syntax, then there is no need to use the
Within ANSI-Common-Lisp syntax, the package names "CL" and "COMMON-LISP" point
to the former package, and the names "CL-USER" and "COMMON-LISP-USER" point to
the latter.  That's part of the functionality of the "Lisp syntax" concept of

There are three advertised ways of using a particular Lisp syntax.  First, you
can include "Syntax: ANSI-Common-Lisp" in your file attribute line.  Second, you
can use the Zmacs command "M-x Set Lisp Syntax".  Lastly, if you are in a Lisp
Listener, you can use the CP command "Set Lisp Context".  (I have no idea why
this is "Context" instead of "Syntax".)  Notice that the status line displays
the current Lisp syntax immediately to the left of the current package name.

>   I still received the error:
>   ...CLASS-PROTOTYPE is undefined error.
>   when loading the system into a clean machine.
>   If i tell the system to use the definition of
>   CLOS:CLASS-PROTOTYPE instead, everything loads.
>   I am definitely on the right track now, but how do i
>   avoid this error?  CLASS-PROTOTYPE is  apparently some
>   subfunction to one of the CLOS functions I call; I don't
>   call it out explicitly.  How do I tell the system that I
>   always want the CLOS definition?

Like all of the major Lisp vendors, Symbolics provides automatic access only to
the "defacto standard" parts of CLOS (e.g., DEFCLASS),  but requires additional
effort to access those parts of CLOS that are not yet standardized, including
the CLOS Meta-Object Protocol (MOP).  In Symbolics' case, "automatic access"
means that only the standard CLOS symbols are inherited by the
"FUTURE-COMMON-LISP" package.  Other "semi-standard" symbols, such as
CLOS:CLASS-PROTOTYPE, are provided as externals in the "CLOS" package.  If you
want these symbols, then you have to explicitly import them into your own
package, or else :USE the "CLOS" package.  If I were to write your package
definition, I would do so in one of the following two ways.

If CLOS:CLASS-PROTOTYPE is the only symbol that you need, then the following is
probably preferred:

;;; Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: CL-USER

(defpackage "ALP-CLOS"
  (:use "COMMON-LISP")
  (:import-from "CLOS" "CLASS-PROTOTYPE"))

However, if you need many semi-standard CLOS symbols, the following gives you
access to all of them:

;;; Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: CL-USER

(defpackage "ALP-CLOS"
  (:use "COMMON-LISP" "CLOS"))

My portable package definitions tend to look like the following:

;;; Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: CL-USER

(cl:defpackage "FOO"
  (:use "COMMON-LISP" "CLIM" <more packages>)
  ;; Import some useful Meta-Object Protocol symbols...

  (:import-from #+(or Genera ExCL Lucid) "CLOS"
	               #+MCL                    "CCL"

  ;; The exports...


Hope this helps!