When I compile the following program:
(defpackage ch17
(:use cl-user))
(in-package ch17)
(deftype element ()
"Elements are objects testable by EQL, namely symbols, characters,
numbers, and packages"
'(satisfies util:elementp))
(defun sub-first (new old l)
"Returns a copy of the list L with the element NEW replacing the
first occurrence of the element OLD."
(check-type new element)
(check-type old element)
(check-type l list)
(cond ((null l) '())
((eql (first l) old) (cons new (rest l)))
(t (cons (first l)
(sub-first new old (rest l))))))
I get the following errors:
Function position must contain a symbol or lambda expression: (NULL L)
Problem detected when processing
((NULL L) 'COMMON-LISP:NIL)
inside (COND ((NULL L) 'COMMON-LISP:NIL) ((EQL # OLD) (CONS NEW #))
...)
inside (DEFUN SUB-FIRST (NEW OLD L) ...)
inside (COMMON-LISP:PROGN COMMON-LISP:NIL
(DEFUN SUB-FIRST (NEW OLD L) ...) ...) ..
[Condition of type COMMON-LISP:PARSE-ERROR]
and the following warnings:
;;; Compiling file /home/rm/src/lisp/shapiro/ch17.lisp
; While compiling (:TOP-LEVEL-FORM "ch17.lisp" 0):
Warning: Free reference to undeclared variable CH17 assumed special.
Warning: Free reference to undeclared variable CL-USER assumed special.
; While compiling (:TOP-LEVEL-FORM "ch17.lisp" 35):
Warning: Free reference to undeclared variable CH17 assumed special.
; While compiling (:TOP-LEVEL-FORM "ch17.lisp" 54):
Warning: Free reference to undeclared variable ELEMENT assumed special.
; While compiling (:TOP-LEVEL-FORM "ch17.lisp" 197):
Warning: Free reference to undeclared variable SUB-FIRST assumed
special.
Warning: Free reference to undeclared variable OLD assumed special.
Warning: Free reference to undeclared variable L assumed special.
Warning: Free reference to undeclared variable NEW assumed special.
Warning: Free reference to undeclared variable ELEMENT assumed special.
Warning: Free reference to undeclared variable LIST assumed special.
The file compiles if I comment-out the (in-package ch17) form. What
can be the problem? Other similar files (with in-package used) compile
without a problem. What causes the compiler to choke on this one?
Any help will be appreciated,
Thanks in advance,
Roshan Mathews
"Roshan Mathews" <········@gmail.com> writes:
> When I compile the following program:
>
> (defpackage ch17
> (:use cl-user))
> (in-package ch17)
[snip]
> I get the following errors:
>
> Function position must contain a symbol or lambda expression: (NULL
> L)
You should not :use the COMMON-LISP-USER package; use the COMMON-LISP
package instead. COMMON-LISP-USER does not typically export any
symbols.
Zach
Zach Beane wrote:
> "Roshan Mathews" <········@gmail.com> writes:
>
> > When I compile the following program:
[snip]
>
> You should not :use the COMMON-LISP-USER package; use the COMMON-LISP
> package instead. COMMON-LISP-USER does not typically export any
> symbols.
Oh, thank you so much. This worked; seems like quite a stupid mistake,
in hindsight. I have been banging me head against this since
yesterday. Thanks again.
Roshan Mathews