[Ecls-list] compiler error: unable to coerce lisp object

Eric Marsden emarsden at laas.fr
Mon Dec 15 10:26:04 UTC 2003


Hi,

Using ECL compiled from CVS on Linux/x86, the code below triggers a
compiler error. 

,----
| > (compile-file "hash")
| ;;; Loading "/usr/local/lib/ecl/cmp.fas"
| ;;; Loading "/usr/local/lib/ecl/sysfun.lsp"
| ;;; Compiling hash.
| ;;; Compiling (EVAL-WHEN (EVAL COMPILE ...) ...).
| ;;; Compiling (PROGN (SI:*MAKE-CONSTANT '+DIGIT+ ...) ...).
| ;;; Compiling (PROGN (SI:*MAKE-CONSTANT '+DIGITS-NEEDED+ ...) ...).
| ;;; Compiling (DEFUN FIXNUM-TO-STRING ...).
| ;;; The variable +DIGITS-NEEDED+ is undefined.
| ;;; The compiler will assume this variable is a global.
| ;;; The variable +DIGIT+ is undefined.
| ;;; The compiler will assume this variable is a global.
| ;;; End of Pass 1.  
| ;;; Emitting code for FIXNUM-TO-STRING.
| ;;; Compiling (DEFUN FIXNUM-TO-STRING).
| ;;; Error: Unable to coerce lisp object from type (NULL,:OBJECT)
| to C/C++ type (FIXNUM,:FIXNUM)
| ;;; Due to errors in the compilation process, no FASL was generated.
`----


(eval-when (:compile-toplevel :load-toplevel)
  (defconstant +digit+ "0123456789ABCDEF")

  (defconstant +digits-needed+
    #((10 100 1000 10000 100000 10000000 100000000 536870911)
      (16 256 4096 65536 1048576 16777216 268435456 4294967296 536870911))))

(defun fixnum-to-string (n base)
  (declare (fixnum n base))
  (let* ((tsize (position-if (lambda (x) (> (the fixnum x) n))
                            (aref +digits-needed+ (ash base -4))))
         (result (make-string (1+ tsize))))
    (loop for i fixnum from tsize downto 0 with q fixnum = n and r fixnum = 0
      do (multiple-value-setq (q r) (floor q base))
         (setf (schar result i) (aref +digit+ r)))
    result))

-- 
Eric Marsden                          <URL:http://www.laas.fr/~emarsden/>





More information about the ecl-devel mailing list