[Openmcl-devel] wrong type of value while writing to matrix (?)

Taylor, Joshua jtaylor at alum.rpi.edu
Wed Dec 5 17:38:50 PST 2007


Hello all,

(If this isn't the appropriate place for this, please let me know. Of
the options I found at http://trac.clozure.com/openmcl/ , this seemed
like what I looking for.)

I used OpenMCL a few years ago, and with all the recent activity, I'm
trying it out again. I started by loading up some code that I'd
written while using LispWorks. I encountered a problem while reading
some matrix values from a file. I've distilled down my problem into
the following code/backtrace that follows. So that you know what
you're looking at, the input file is from Project Euler, and is
http://projecteuler.net/project/matrix.txt (but with the commas
replaced with spaces). I create an 80x80 matrix and read values from
the file and write them into the matrix. Unless I put an element-type
for the matrix, I get "Error: value 1664882 is not of the expected
type (SIMPLE-ARRAY T (* *))." I don't seem to get this with a smaller
array though. As for version information, I'm on an iBook G4 running
OS X 10.4.10, and
Welcome to OpenMCL Version 1.1-pre-070722 (DarwinPPC32)!
? (lisp-implementation-type) => "OpenMCL"
? (lisp-implementation-version) => "Version 1.1-pre-070722 (DarwinPPC32)"
? (type-of (make-array '(80 80))) => (SIMPLE-ARRAY T (80 80))

I hope I'm just missing something silly. Thanks in advance!

^_^ tayloj at hobbang:~$ cat foo.lisp
(defun load-matrix ()
  (let ((matrix (make-array '(80 80))))
    (with-open-file (in "~/Desktop/Project Euler/matrix.txt")
      (dotimes (i 80)
        (dotimes (j 80)
          (setf (aref matrix i j) (read in) ))))
    matrix))

(defun load-matrix2 ()
  (let ((matrix (make-array '(80 80) :element-type 'fixnum)))
    (with-open-file (in "~/Desktop/Project Euler/matrix.txt")
      (dotimes (i 80)
        (dotimes (j 80)
          (setf (aref matrix i j) (read in) ))))
    matrix))

^_^ tayloj at hobbang:~$ openmcl -l foo.lisp
Welcome to OpenMCL Version 1.1-pre-070722 (DarwinPPC32)!
? (load-matrix2) ; with element-type
#2A((4445 2697 5115 ... 9491 1937 7384 4563 6842 5432 2751 3406 7981))
? (load-matrix) ; without element-type
> Error: value 1664882 is not of the expected type (SIMPLE-ARRAY T (* *)).
> While executing: LOAD-MATRIX, in process listener(1).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 > :b :show-frame-contents t
(F0199B80) : 0 (LOAD-MATRIX) 304
  NIL

  MATRIX: #2A((0 0 0 0 0 ...) (0 0 0 0 0 ...) (0 0 0 0 0 ...) (0 0 0 0
0 ...) (0 0 0 0 0 ...) ...)
  #:G0: #<BASIC-FILE-CHARACTER-INPUT-STREAM
("/Users/tayloj/Desktop/Project Euler/matrix.txt"/4 ISO-8859-1)
#x855850E>
  #:G1: NIL
  IN: #<BASIC-FILE-CHARACTER-INPUT-STREAM
("/Users/tayloj/Desktop/Project Euler/matrix.txt"/4 ISO-8859-1)
#x855850E>
  I: 0
  J: 0

(F0199BA0) : 2 (CALL-CHECK-REGS 'LOAD-MATRIX [...]) 72
  (CCL::FN &REST CCL::ARGS)
   CCL::FN: LOAD-MATRIX
   CCL::ARGS: NIL

  CCL::OLD-REGS: (*PACKAGE* #<SYNONYM-STREAM to *TERMINAL-IO*
#x852BDA6> (NIL) (#) 0 ...)

(F0199BC0) : 4 (TOPLEVEL-EVAL '(LOAD-MATRIX) [...]) 152
  (CCL::FORM &OPTIONAL *LOADING-FILE-SOURCE-FILE*)
   CCL::FORM: (LOAD-MATRIX)
   *LOADING-FILE-SOURCE-FILE*: NIL

  PACKAGE: #<Package "COMMON-LISP-USER">

(F0199BD0) : 5 (READ-LOOP [...]) 888
  (&KEY :INPUT-STREAM :OUTPUT-STREAM :BREAK-LEVEL :PROMPT-FUNCTION)
   INPUT-STREAM: 0
   OUTPUT-STREAM: #<SYNONYM-STREAM to *TERMINAL-IO* #x852BBAE>
   CCL::BREAK-LEVEL: #<BASIC-FILE-CHARACTER-INPUT-STREAM
("/Users/tayloj/Desktop/Project Euler/matrix.txt"/4 ISO-8859-1)
#x855850E>
   CCL::PROMPT-FUNCTION: #<Anonymous Function #x81D0466>

  CCL::*BREAK-LEVEL*: 0
  CCL::*LAST-BREAK-LEVEL*: 0
  *LOADING-FILE-SOURCE-FILE*: NIL
  CCL::*IN-READ-LOOP*: NIL
  ***: NIL
  **: NIL
  *: #2A((4445 2697 5115 718 2209 ...) (1096 20 1318 7586 5167 ...)
(9607 7385 521 6084 1364 ...) (7206 3114 7760 1094 6150 ...) (3620
8024 577 9997 7377 ...) ...)
  +++: NIL
  ++: NIL
  +: (LOAD-MATRIX2)
  ///: NIL
  //: NIL
  /: (#2A(# # # # # ...))
  -: (LOAD-MATRIX)
  CCL::EOF-VALUE: #2A((0 0 0 0 0 ...) (0 0 0 0 0 ...) (0 0 0 0 0 ...)
(0 0 0 0 0 ...) (0 0 0 0 0 ...) ...)
  #:ABORT-BREAK: #<RESTART ABORT-BREAK #x76AC56>
  #:ABORT: #<RESTART ABORT #x76AC2E>
  #:G28539: (#<RESTART ABORT #x76AC2E> #<RESTART ABORT-BREAK #x76AC56>)
  CCL::%RESTARTS%: ((#<# # #x76AC2E> #<# # #x76AC56>) (#<# # #x76AD8E>
#<# # #x76ADB6>))
  CCL::FORM: (LOAD-MATRIX)
  CCL::PATH: NIL
  CCL::PRINT-RESULT: T

(F0199C10) : 6 (TOPLEVEL-LOOP) 72
  NIL



(F0199C30) : 7 (FUNCALL #'#<Anonymous Function #x816CCEE>) 68
  NIL

  CCL::INIT-FILE: "home:openmcl-init"

(F0199C50) : 9 (FUNCALL #'#<Anonymous Function #x82161AE>) 336
  NIL

  CCL::CLOSE-STREAMS: NIL
  CCL::CLEANUP-FUNCTION: #<COMPILED-LEXICAL-CLOSURE #x852BA2E>
  CCL::INITIAL-FUNCTION: #<COMPILED-LEXICAL-CLOSURE #x852BA16>
  OUTPUT-STREAM: #<BASIC-CHARACTER-OUTPUT-STREAM ISO-8859-1 (TTY/1) #x852C94E>
  INPUT-STREAM: #<BASIC-CHARACTER-INPUT-STREAM ISO-8859-1 (TTY/0) #x852CEFE>
  *TERMINAL-IO*: #<ECHOING-TWO-WAY-STREAM input
#<BASIC-CHARACTER-INPUT-STREAM ISO-8859-1 (TTY/0) #x852CEFE>, output
#<BASIC-CHARACTER-OUTPUT-STREAM ISO-8859-1 (TTY/1) #x852C94E>
#x853FDCE>

(F0199C70) : 10 (RUN-PROCESS-INITIAL-FORM #<TTY-LISTENER listener(1)
[Active] #x852B666> '(#)) 400
  (PROCESS CCL::INITIAL-FORM)
   PROCESS: #<TTY-LISTENER listener(1) [Active] #x852B666>
   CCL::INITIAL-FORM: (#<COMPILED-LEXICAL-CLOSURE #x852B2B6>)

  CCL::EXITED: NIL
  #:G28844: (PROCESS-RESET)
  CCL::%HANDLERS%: ((PROCESS-RESET))
  #:ABORT: #<RESTART ABORT #x76ADB6>
  #:ABORT-BREAK: #<RESTART ABORT-BREAK #x76AD8E>
  #:G28845: (#<RESTART ABORT-BREAK #x76AD8E> #<RESTART ABORT #x76ADB6>)
  CCL::%RESTARTS%: ((#<# # #x76AD8E> #<# # #x76ADB6>))

(F0199CB0) : 12 (FUNCALL #'#<Anonymous Function #x8173F66>
#<TTY-LISTENER listener(1) [Active] #x852B666> '(#)) 152
  (PROCESS CCL::INITIAL-FORM)
   PROCESS: #<TTY-LISTENER listener(1) [Active] #x852B666>
   CCL::INITIAL-FORM: (#<COMPILED-LEXICAL-CLOSURE #x852B2B6>)

  *CURRENT-PROCESS*: #<TTY-LISTENER listener(1) [Active] #x852B666>
  CCL::SYMS: (CCL::*FREE-XPS* CCL::*FREE-CIRCULARITY-HASH-TABLES*
CCL::*FAKE-STACK-FRAMES* CCL::*VINSN-VARPARTS*
CCL::*VINSN-LABEL-FREELIST* ...)
  VALUES: (NIL NIL NIL #<POOL  #x853FFAE> #<POOL  #x853FF96> ...)

(F0199CD0) : 13 (FUNCALL #'#<Anonymous Function #x816AAB6>) 172
  NIL

  CCL::TCR: 787548
  CCL::THREAD: #<LISP-THREAD listener [tcr @ #x301170] #x852B95E>
  CCL::*CURRENT-LISP-THREAD*: #<LISP-THREAD listener [tcr @ #x301170] #x852B95E>
  CCL::INITIAL-FUNCTION: (#<Anonymous Function #x8173F66>
#<TTY-LISTENER listener(1) [Active] #x852B666> (#))

1 > (quit)
^_^ tayloj at hobbang:~$

-- 
=====================
Joshua Taylor
jtaylor at alum.rpi.edu

"A lot of good things went down one time,
     back in the goodle days."
               John Hartford



More information about the Openmcl-devel mailing list