Discussion:
[PATCH] make defpackage form fully describe package's state
Tobias C. Rittweiler
2009-09-15 16:06:03 UTC
Permalink
CLHS specifies that consequences are undefined if a defpackage form (on
evaluation) does not fully describe the package's state. And, indeed,
SBCL signals a warning in that case.

That means that (progn (asdf:oos 'asdf:load-op :closer-mop :force t)
(asdf:oos 'asdf:load-op :closer-mop :force t))
will fail on SBCL.

The attached patch makes the effort to generate a DEFPACKAGE form which
correctly describes the final state of the package it defines.

-T.
Tobias C. Rittweiler
2009-09-15 17:08:13 UTC
Permalink
Uhm, for some reason that escapes me, the diff below came in
reversed. You have to apply it by passing the -R flag to patch.

-T.
Post by Tobias C. Rittweiler
CLHS specifies that consequences are undefined if a defpackage form (on
evaluation) does not fully describe the package's state. And, indeed,
SBCL signals a warning in that case.
That means that (progn (asdf:oos 'asdf:load-op :closer-mop :force t)
(asdf:oos 'asdf:load-op :closer-mop :force t))
will fail on SBCL.
The attached patch makes the effort to generate a DEFPACKAGE form which
correctly describes the final state of the package it defines.
-T.
--- old-closer-mop/closer-mop-utility-packages.lisp 2009-09-15 17:58:23.000000000 +0200
+++ new-closer-mop/closer-mop-utility-packages.lisp 2009-09-15 17:58:23.000000000 +0200
@@ -1,22 +1,17 @@
(in-package :cl-user)
-;;; We have to make sure that the DEFPACKAGE form fully describes the
-;;; state of the package as CLHS specifies the consequences to be
-;;; undefined otherwise. And SBCL annoyingly^W rightfully signals
-;;; a warning in the case of reloading.
-(macrolet
- ((define-closer-cl-package (name &body options)
- `(defpackage ,name
- if (find-symbol (symbol-name sym) :c2mop)
- collect it
- else collect sym))
- collect sym)))))
-
- (define-closer-cl-package #:closer-common-lisp
- (:nicknames #:c2cl)))
+(defpackage #:closer-common-lisp
+ (:nicknames #:c2cl)
+ (:use))
+
+(let ((syms (nunion (loop for sym being the external-symbols of :common-lisp
+ if (find-symbol (symbol-name sym) :c2mop)
+ collect it
+ else collect sym)
+ (loop for sym being the external-symbols of :c2mop
+ collect sym))))
+ (import syms :c2cl)
+ (export syms :c2cl))
(defpackage #:closer-common-lisp-user
(:nicknames #:c2cl-user)
Pascal Costanza
2009-09-16 10:46:39 UTC
Permalink
Hi Tobias,

Thanks a lot for the bug report. I had to find a different way to fix
this, to make sure that this also works in Common Lisp implementations
other than SBCL. ;)

But this was a good catch, so thanks indeed!

Best,
Pascal
Post by Tobias C. Rittweiler
Uhm, for some reason that escapes me, the diff below came in
reversed. You have to apply it by passing the -R flag to patch.
-T.
Post by Tobias C. Rittweiler
CLHS specifies that consequences are undefined if a defpackage form (on
evaluation) does not fully describe the package's state. And, indeed,
SBCL signals a warning in that case.
That means that (progn (asdf:oos 'asdf:load-op :closer-mop :force t)
(asdf:oos 'asdf:load-op :closer-mop :force t))
will fail on SBCL.
The attached patch makes the effort to generate a DEFPACKAGE form which
correctly describes the final state of the package it defines.
-T.
--- old-closer-mop/closer-mop-utility-packages.lisp 2009-09-15 17:58:23.000000000 +0200
+++ new-closer-mop/closer-mop-utility-packages.lisp 2009-09-15 17:58:23.000000000 +0200
@@ -1,22 +1,17 @@
(in-package :cl-user)
-;;; We have to make sure that the DEFPACKAGE form fully describes the
-;;; state of the package as CLHS specifies the consequences to be
-;;; undefined otherwise. And SBCL annoyingly^W rightfully signals
-;;; a warning in the case of reloading.
-(macrolet
- ((define-closer-cl-package (name &body options)
- `(defpackage ,name
- if (find-symbol (symbol-name
sym) :c2mop)
- collect it
- else collect sym))
- collect sym)))))
-
- (define-closer-cl-package #:closer-common-lisp
- (:nicknames #:c2cl)))
+(defpackage #:closer-common-lisp
+ (:nicknames #:c2cl)
+ (:use))
+
+(let ((syms (nunion (loop for sym being the external-symbols
of :common-lisp
+ if (find-symbol (symbol-name sym) :c2mop)
+ collect it
+ else collect sym)
+ (loop for sym being the external-symbols
of :c2mop
+ collect sym))))
+ (import syms :c2cl)
+ (export syms :c2cl))
(defpackage #:closer-common-lisp-user
(:nicknames #:c2cl-user)
_______________________________________________
closer-devel mailing list
http://common-lisp.net/cgi-bin/mailman/listinfo/closer-devel
--
Pascal Costanza, mailto:***@p-cos.net, http://p-cos.net
Vrije Universiteit Brussel
Software Languages Lab
Pleinlaan 2, B-1050 Brussel, Belgium
Tobias C. Rittweiler
2009-09-16 14:44:29 UTC
Permalink
Post by Pascal Costanza
Hi Tobias,
Thanks a lot for the bug report. I had to find a different way to fix
this, to make sure that this also works in Common Lisp implementations
other than SBCL. ;)
Why shouldn't it?

-T.
Pascal Costanza
2009-09-16 17:41:03 UTC
Permalink
Post by Tobias C. Rittweiler
Post by Pascal Costanza
Hi Tobias,
Thanks a lot for the bug report. I had to find a different way to fix
this, to make sure that this also works in Common Lisp
implementations
other than SBCL. ;)
Why shouldn't it?
...because in some versions of Closer to MOP for some Common Lisp
implementations, I shadow and redefine things like defgeneric,
defmethod, standard-generic-function, and the likes, which are also
defined in the COMMON-LISP and CLOS packages of the respective
implementations.


Pascal
--
Pascal Costanza, mailto:***@p-cos.net, http://p-cos.net
Vrije Universiteit Brussel
Software Languages Lab
Pleinlaan 2, B-1050 Brussel, Belgium
Loading...