[armedbear-devel] Package redefinition issue in REPL.
Hello dear developers, I' just experienced an odd issue with defpackage. It looked like the package will not be modified if I call defpackage again. For example, I define a package called "a-package". After a while I wanted to export a function that I've just implemented called "a-new-foo". Naturally I would add a new entry under the :export section of defpackage, and then eval the expression again. However, I still cannot access "a-new-foo" as the REPL gives me "such symbol is not external of package [a-package]" error message. Please advice and many thanks, Wei-Lun Chiu
wl chiu <wlclive@live.com> writes:
Hello dear developers,
I' just experienced an odd issue with defpackage. It looked like the package will not be modified if I call defpackage again.
For example, I define a package called "a-package". After a while I wanted to export a function that I've just implemented called "a-new-foo". Naturally I would add a new entry under the :export section of defpackage, and then eval the expression again. However, I still cannot access "a-new-foo" as the REPL gives me "such symbol is not external of package [a-package]" error message.
Please advice and many thanks,
I don't know what the intent of ABCL is, but this behavior is allowed by the specification of DEFPACKAGE: If defined-package-name already refers to an existing package, the name-to-package mapping for that name is not changed. If the new definition is at variance with the current state of that package, the consequences are undefined; an implementation might choose to modify the existing package to reflect the new definition. You can modify the export status of a symbol reliably at runtime with the EXPORT function. Zach
----------------------------------------
From: xach@xach.com To: wlclive@live.com CC: armedbear-devel@common-lisp.net Subject: Re: [armedbear-devel] Package redefinition issue in REPL. Date: Wed, 25 Apr 2012 07:01:07 -0400
wl chiu <wlclive@live.com> writes:
Hello dear developers,
I' just experienced an odd issue with defpackage. It looked like the package will not be modified if I call defpackage again.
For example, I define a package called "a-package". After a while I wanted to export a function that I've just implemented called "a-new-foo". Naturally I would add a new entry under the :export section of defpackage, and then eval the expression again. However, I still cannot access "a-new-foo" as the REPL gives me "such symbol is not external of package [a-package]" error message.
Please advice and many thanks,
I don't know what the intent of ABCL is, but this behavior is allowed by the specification of DEFPACKAGE:
If defined-package-name already refers to an existing package, the name-to-package mapping for that name is not changed. If the new definition is at variance with the current state of that package, the consequences are undefined; an implementation might choose to modify the existing package to reflect the new definition.
You can modify the export status of a symbol reliably at runtime with the EXPORT function.
Zach
Thank you very much! I guess for now I have to rely on the function "export" during the development. I do hope one day the modification behavior will be implemented :) Best regards, Wei-Lun Chiu
wl chiu <wlclive@live.com> writes:
Thank you very much! I guess for now I have to rely on the function "export" during the development. I do hope one day the modification behavior will be implemented :)
Why wait? This is lisp! (shadow 'defpackage) (defmacro defpackage (…) `(eval-when (…) (if (find-package name) (progn (rename-package …) (intern …) (import …) (export …) … ',name) (cl:defpackage …)))) -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}.
On Apr 27, 2012, at 2:06 PM, Pascal J. Bourguignon wrote:
wl chiu <wlclive@live.com> writes:
Thank you very much! I guess for now I have to rely on the function "export" during the development. I do hope one day the modification behavior will be implemented :)
Why wait? This is lisp!
(shadow 'defpackage)
(defmacro defpackage (…)
[…] Two prehensile thumbs up! -- "A screaming comes across the sky. It has happened before, but there is nothing to compare to it now."
participants (4)
-
Mark Evenson
-
Pascal J. Bourguignon
-
wl chiu
-
Zach Beane