Lisp HUG Maillist Archive

defconstant and #.

If the following 3 forms:

(in-package :cl-user)

(defconstant +frob+ 42)

(defun foo ()
   (+ 1 #.+frob+))

are saved to a "file.lisp" then under lispworks 5.0.2 on FreeBSD (load 
"file.lisp") works fine but (compile-file "file.lisp") produces this error:

**++++ Error between functions: 
 

   The variable +FROB+ is unbound. 
 

; (TOP-LEVEL-FORM 3) 
 

; *** 1 error detected, no fasl file produced.

My SBCL 1.0.11 produces no such error.

I suspect this is acceptable behaviour per the spec but have been unable 
to find a truly satisfactory reference on the InterWeb.  Comment 
appreciated.

Cheers,

Greg


Re: defconstant and #.

Hi,

I think a "right" lisp compiler will do that (don't know +frob+ at  
compile time), use a EVAL-WHEN should fix:

P.S. If you want to use +frob+ at runtime, EVAL-WHEN should also  
add :LOAD-TOPLEVEL & :EXECUTE

>
> If the following 3 forms:
>
> (in-package :cl-user)
>

(eval-when (:compile-toplevel)
> (defconstant +frob+ 42)
)

>
>
> (defun foo ()
>  (+ 1 #.+frob+))
>
> are saved to a "file.lisp" then under lispworks 5.0.2 on FreeBSD  
> (load "file.lisp") works fine but (compile-file "file.lisp")  
> produces this error:
>
> **++++ Error between functions:
>  The variable +FROB+ is unbound.
> ; (TOP-LEVEL-FORM 3)
> ; *** 1 error detected, no fasl file produced.
>
> My SBCL 1.0.11 produces no such error.
>
> I suspect this is acceptable behaviour per the spec but have been  
> unable to find a truly satisfactory reference on the InterWeb.   
> Comment appreciated.
>
> Cheers,
>
> Greg
>


Re: defconstant and #.

http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node68.html#SECTION00933000000000000000

>
> If the following 3 forms:
>
> (in-package :cl-user)
>
> (defconstant +frob+ 42)
>
> (defun foo ()
>  (+ 1 #.+frob+))
>
> are saved to a "file.lisp" then under lispworks 5.0.2 on FreeBSD  
> (load "file.lisp") works fine but (compile-file "file.lisp")  
> produces this error:
>
> **++++ Error between functions:
>  The variable +FROB+ is unbound.
> ; (TOP-LEVEL-FORM 3)
> ; *** 1 error detected, no fasl file produced.
>
> My SBCL 1.0.11 produces no such error.
>
> I suspect this is acceptable behaviour per the spec but have been  
> unable to find a truly satisfactory reference on the InterWeb.   
> Comment appreciated.
>
> Cheers,
>
> Greg
>


Updated at: 2020-12-10 08:43 UTC