[Asdf-devel] Program with metaclass on MKCL.

Pascal J. Bourguignon pjb at informatimago.com
Thu Dec 4 10:26:50 UTC 2014

"D. Martinez" <denis.martinez at live.com> writes:

> Hello. Being new to "serious" CL programming I am hitting a brick wall right now in one CLOS project.
> After some time of infructuous searching I cannot find the source of
> my problem, which may be of either MKCL or ASDF but I lack the
> knowledge to debug this. Mr. JCB, who I have seen active on this list,
> may (hopefully!) be able to shed some light on the issue.
> The bug I encounter happens when I load the project by the means of
> ASDF. I can not reproduce it otherwise.
> It is triggered by a use of a custom metaclass, and it suggests that a
> file is loaded more times than it should.
> I have narrowed down the problem to a small program, so here it is:
> ;;;; hello.asd
> (asdf:defsystem #:hello
>     :description "Describe hello here"
>     :author "Your Name <your.name at example.com>"
>     :license "Specify license here"
>     :serial t
>     :components ((:file "package")
>                  (:file "a"))
>     :depends-on ())
> ;;;; package.lisp
> (defpackage #:hello
>   (:use #:cl))
> ;;;; a.lisp
> (in-package #:hello)
> (defclass A-class (standard-class)
>   ())
> (defclass A (standard-object)
>   () (:metaclass A-class))

AFAIK, you need to define a validate-superclass method when you define a
new metaclass:

---- a.lisp ------------------------------------------------------------
(in-package #:hello)
(defclass A-class (standard-class)
(defmethod validate-superclass ((class A-class) (super standard-class))
(defclass A (standard-object)
  (:metaclass A-class))
---- hello.asd ---------------------------------------------------------
(asdf:defsystem #:hello
  :description "Describe hello here"
  :author "Your Name <your.name at example.com>"
  :license "Specify license here"
  :serial t
  :components ((:file "package")
               (:file "a"))
  :depends-on ("closer-mop"))
---- package.lisp ------------------------------------------------------
(defpackage #:hello
  (:use #:cl)
  (:import-from #:closer-mop #:validate-superclass))

> I will happily provide more specific info at request. The bug occured
> on MKCL 1.1.9 and 1.1.10 git with bundled ASDF.

I tested it with ccl.

__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk

More information about the asdf-devel mailing list