I've a beginner's question regarding packages in LISP:
I'm writing a task analysis tool for students that requires me to have
a macro named "step" (the syntax of the tool is given, so I can't
simply choose a different name). Since "step" is already the name of a
CL function, I decided to use an own package ("GOMS") to define my
stuff. When I compile my code, I get the error message
Error: Attempt to make a FUNCTION definition for the name STEP as a
MACRO. This name is in the COMMON-LISP package and redefining it is a
violation for portable programs. Replacing the current definition of
#<macro STEP @ #x20686922> may be dangerous. The package COMMON-LISP
has EXCL:PACKAGE-DEFINITION-LOCK set, which causes the system to
signal this violation.
When I choose to overwrite and inspect (ACL 5.0.1) goms::step, it is
defined in the cl package (all other symbols I use are defined in the
goms package).
I thought, packages are used exactly to circumvent this kind of
problems. Why can't I use the symbol step twice, one in the cl package
and one in the goms package? How can I grant my users the use of the
symbol step without running into problems?
"Wolfgang" <··········@hotmail.com> wrote in message
·································@posting.google.com...
>
> When I choose to overwrite and inspect (ACL 5.0.1) goms::step, it is
> defined in the cl package (all other symbols I use are defined in the
> goms package).
> I thought, packages are used exactly to circumvent this kind of
> problems. Why can't I use the symbol step twice, one in the cl package
> and one in the goms package? How can I grant my users the use of the
> symbol step without running into problems?
Packages are used, it's called shadowing.
http://www.lispworks.com/reference/HyperSpec/Body/11_aabe.htm
Also:
defpackage -> :shadow
shadow
shadowing-import
--
Geoff
··········@hotmail.com (Wolfgang) writes:
> I've a beginner's question regarding packages in LISP:
> I'm writing a task analysis tool for students that requires me to have
> a macro named "step" (the syntax of the tool is given, so I can't
> simply choose a different name). Since "step" is already the name of a
> CL function, I decided to use an own package ("GOMS") to define my
> stuff. When I compile my code, I get the error message
>
> Error: Attempt to make a FUNCTION definition for the name STEP as a
> MACRO. This name is in the COMMON-LISP package and redefining it is a
> violation for portable programs. Replacing the current definition of
> #<macro STEP @ #x20686922> may be dangerous. The package COMMON-LISP
> has EXCL:PACKAGE-DEFINITION-LOCK set, which causes the system to
> signal this violation.
>
> When I choose to overwrite and inspect (ACL 5.0.1) goms::step, it is
> defined in the cl package (all other symbols I use are defined in the
> goms package).
> I thought, packages are used exactly to circumvent this kind of
> problems. Why can't I use the symbol step twice, one in the cl package
> and one in the goms package? How can I grant my users the use of the
> symbol step without running into problems?
If your goms package uses the cl package (which it probably will),
goms::step and cl:step are exactly the same symbol, they are eq. So
redefining goms::step would also redefine cl:step. You have to shadow
it, like this:
(defpackage "GOMS"
(:use "COMMON-LISP")
(:shadow "STEP"))