[cells-devel] bug report w/patch for record-caller in link.lisp, in LWL 5.1
Kenny Tilton
kennytilton at optonline.net
Mon Sep 1 16:23:34 UTC 2008
Thanks, I'll put it in my working code base, but I have not committed to
CVS in a while and not sure when I will again.
I have always hated that code. Not sure why I did not just use an
integer and logical operations.
kt
Larry Clapp wrote:
> Bug report:
>
> Running Stefano's Sudoku example from his cells-doc in Lispworks for
> Linux 5.1, got an error in record-caller:
>
> Error: The subscript 16 exceeds the limit 15 for the first dimension
> of the array #*1111111111111111.
> 1 (abort) Return to level 0.
> 2 Return to top loop level 0.
>
> Lispworks said the offending code was at the indicated line:
>
> (handler-case
> (setf (sbit (cd-usage *depender*) used-pos) 1) ; <== ### here ###
> (type-error (error)
> (declare (ignorable error))
> (setf (cd-usage *depender*)
> (adjust-array (cd-usage *depender*) (+ used-pos 16) :initial-element 0))
> (setf (sbit (cd-usage *depender*) used-pos) 1))))
>
> Fix:
>
> The condition reported was of type CONDITIONS:SUBSCRIPT-OUT-OF-BOUNDS.
> I added that to the handler-case, and then it worked:
>
> (handler-case
> (setf (sbit (cd-usage *depender*) used-pos) 1)
> ((or type-error conditions:subscript-out-of-bounds) (error)
> ;^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> (declare (ignorable error))
> (setf (cd-usage *depender*)
> (adjust-array (cd-usage *depender*) (+ used-pos 16) :initial-element 0))
> (setf (sbit (cd-usage *depender*) used-pos) 1))))
>
> However, this seems like a demonstrably error-prone way to handle this
> particular situation, so I got rid of the handler-case entirely and
> tried this:
>
> (let ((cd-usage (cd-usage *depender*)))
> (when (>= used-pos (array-dimension cd-usage 0))
> (setf cd-usage
> (setf (cd-usage *depender*)
> (adjust-array (cd-usage *depender*)
> (+ used-pos 16)
> :initial-element 0))))
> (setf (sbit cd-usage used-pos) 1))
>
> It works, doesn't depend on implementation-specific conditions, and in
> my limited testing (I ran the sudoku solver three times using each
> version), seems at least as fast, if not a tiny bit faster.
>
> -- Larry
>
> _______________________________________________
> cells-devel site list
> cells-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/cells-devel
>
--
http://www.theoryyalgebra.com/
More information about the cells-devel
mailing list