From: Cecil W. <Ce...@de...> - 2010-07-30 04:43:50
|
What I am describing here is happening in Emacs/Smile. In another file I have: (defmacro define-constant (name value &optional doc) `(defconstant ,name (if (boundp ',name) (symbol-value ',name) ,value) ,@(when doc (list doc)))) Took it from the Internet. Should properly be bettered: it is an error when name is already defined and has another value. The definition is included with: (load (merge-pathnames "clisp/script-utils" (user-homedir-pathname))) But when doing: (define-constant +db+ (merge-pathnames "recepten.db" (user-homedir-pathname))) there is an error. The folowing does work: (defvar +db+ (merge-pathnames "recepten.db" (user-homedir-pathname))) Variables and functions defined in ~/clisp/script-utils do not have a problem. (As far as I know.) When giving 'C-x C-e' after the definition of define-constant I can use define-constant. What am I doing wrong? I also tried it in sbcl standalone and there I got: * (load (merge-pathnames "clisp/script-utils" (user-homedir-pathname))) T * (define-constant +db+ (merge-pathnames "recepten.db" (user-homedir-pathname))) ; in: DEFINE-CONSTANT +DB+ ; (DEFINE-CONSTANT +DB+ (MERGE-PATHNAMES "recepten.db" (USER-HOMEDIR-PATHNAME))) ; ; caught WARNING: ; undefined variable: +DB+ ; ; caught STYLE-WARNING: ; undefined function: DEFINE-CONSTANT ; ; compilation unit finished ; Undefined function: ; DEFINE-CONSTANT ; Undefined variable: ; +DB+ ; caught 1 WARNING condition ; caught 1 STYLE-WARNING condition debugger invoked on a UNBOUND-VARIABLE in thread #<THREAD "initial thread" RUNNING {A9FA801}>: The variable +DB+ is unbound. When defining define-constant manually I get: (defmacro define-constant (name value &optional doc) `(defconstant ,name (if (boundp ',name) (symbol-value ',name) ,value) ,@(when doc (list doc)))) STYLE-WARNING: DEFINE-CONSTANT is being redefined as a macro when it was previously assumed to be a function. DEFINE-CONSTANT and then executing the macro gives the expected result. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof |