[Ecls-list] Overwriting cl functions
Juan Jose Garcia-Ripoll
juanjose.garciaripoll at gmail.com
Sun Mar 31 08:43:33 UTC 2013
On Tue, Jan 29, 2013 at 6:39 PM, Peter Enerccio <enerccio at gmail.com> wrote:
> Well I tried the shadowing import, compiles fine, but when attempting to
> load that fas, it will throw redefinition error
>
Sorry for answering so late, but I just started to scan for unread emails.
The problem with your code is that SHADOWING-IMPORT is importing the
CL:OPEN symbol into your package Thus you are redefining CL:OPEN.
What you should instead do is define your I/O package and define a symbol
OPEN in it and SHADOWING-IMPORT it from _other_ packages.
(defpackage my-io
(:shadow :open))
(defun open (...)
...)
(defpackage other-package
(:use :cl :my-io)
(:shadowing-import-from :my-io :open))
A probably simpler way to achieve the same would be to do a replacement
package for CL. You would do
(defpackage :my-cl
(:use :cl)
(:shadow :open)
(:export :open))
(let ((p (find-package "MY-CL")))
(do-external-symbols (s (find-package "CL"))
(unless (string-equal "OPEN" s)
(export s p))))
(defpackage :my-other
(:use :my-cl))
(print (symbol-package (find-symbol "OPEN" (find-package "MY-OTHER"))))
=> prints MY-OTHER
(print (symbol-package (find-symbol "COS" (find-package "MY-OTHER"))))
=> prints COMMON-LISP
--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20130331/206aec90/attachment.html>
More information about the ecl-devel
mailing list