[Ecls-list] possible ecl bug

Geo Carncross geocar at gmail.com
Wed May 28 00:20:01 UTC 2008


This trim-whitespace implementation won't compile in ecl:

ECL (Embeddable Common-Lisp) 0.9j (CVS 2008-05-20 14:05)
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.  Top level.
> (defun trim-whitespace (string)
  "Returns a version of the string STRING where spaces and tab
characters are trimmed from the start and the end.  Might return
STRING."
  ;; optimized version to replace STRING-TRIM, suggested by Jason Kantz
  (declare (optimize
            speed
            (safety 0)
            (space 0)
            (debug 1)
            (compilation-speed 0)
            #+:lispworks (hcl:fixnum-safety 0)))
  (declare (string string))
  (let* ((length (length string))
         (start (loop for i of-type fixnum from 0 below length
                      while (or (char= #\space (char string i))
                                (char= #\tab (char string i)))
                      finally (return i)))
         (end (loop for i of-type fixnum downfrom (1- length) to 0
                    while (or (char= #\space (char string i))
                              (char= #\tab (char string i)))
                    finally (return (1+ i)))))
    (declare (fixnum start end))
    (cond ((and (zerop start) (= end length)) string)
          (t (subseq string start end)))))
TRIM-WHITESPACE

> (compile 'trim-whitespace)
;;; Loading #P"/usr/local/lib/ecl/cmp.fas"
;;; Loading #P"/usr/local/lib/ecl/sysfun.lsp"
;;; Note: In function TRIM-WHITESPACE, checking types of arguments STRING.
;;; Note: Unable to emit check for variable (OPTIONAL-CHECK-TYPE STRING STRING)
;;; End of Pass 1.
;;; Note: Replacing variable G125 by its value
;;; Compiling C::|compiler preprocess|.
;;; Error: Unable to coerce lisp object from type (NULL,:OBJECT)
to C/C++ type (FIXNUM,:FIXNUM)
;;; Failed to compile TRIM-WHITESPACE.




More information about the ecl-devel mailing list