Re: Lisp built in functions and packages
- From: Rainer Joswig <joswig@xxxxxxx>
- Date: Thu, 13 Dec 2007 04:07:33 +0100
In article
<61329624-d66c-4bf6-857f-c5b55819b6c8@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"metaperl.com" <metaperl@xxxxxxxxx> wrote:
Per this earlier thread:
http://groups.google.com.ua/group/comp.lang.lisp/browse_thread/thread/0d153c516b0ee506
it was stated that a certain function could not be defined because it
is a built-in function in common-lisp.
I am having the same issue. I want to define floor within my own
package, but am getting
Lock on package COMMON-LISP violated when setting fdefinition of
FLOOR.
but to my mind, if I define the floor function within my package, why
should it conflict?
Because your package uses the COMMON-LISP package, maybe?
Show your DEFPACKAGE form.
Remember, when you don't have a :USE option, an implementation dependent
list of packages will be USED.
(in-package :re***)
(defconstant floor-rank 0
"The floor verb operates on atoms, so its default rank is 0" )
(defun floor-core (num)
"Given a number, get its floor"
(cl:floor num))
(defun floor (noun)
"Apply floor-core to NOUN considering floor-rank"
(monad-apply #'floor-core noun floor-rank))
So, how is the package RE*** defined? Does it use COMMON-LISP.
Do a (describe (find-package "RE***")) and see what is says.
If you want to have your own symbols with names that are already used in
the COMMON-LISP package you can
a) not import the COMMON-LISP package in your package
(and selectively import the symbols you want to use)
b) SHADOW symbols from packages that you use. You can import all
symbols, with the exception of the ones you shadow.
? (defpackage "FOO" (:use "COMMON-LISP") (:shadow "FLOOR"))
#<Package "FOO">
? (in-package "FOO")
#<Package "FOO">
? (describe 'floor)
Symbol: FLOOR
INTERNAL in package: #<Package "FOO">
Print name: "FLOOR"
Value: #<Unbound>
Function: #<Unbound>
Plist: NIL
? (describe 'cl:floor)
Symbol: COMMON-LISP:FLOOR
Function
EXTERNAL in package: #<Package "COMMON-LISP">
Print name: "FLOOR"
Value: #<Unbound>
Function: #<Compiled-function COMMON-LISP:FLOOR #x300040082F2F>
Arglist: (NUMBER &OPTIONAL CCL::DIVISOR)
Plist: NIL
? (defun floor () 'foo)
FLOOR
--
http://lispm.dyndns.org/
.
- References:
- Lisp built in functions and packages
- From: metaperl.com
- Lisp built in functions and packages
- Prev by Date: Lisp built in functions and packages
- Next by Date: Re: Lisp built in functions and packages
- Previous by thread: Lisp built in functions and packages
- Next by thread: Re: Lisp built in functions and packages
- Index(es):
Loading