djk@vail.cs.columbia.edu (David Kurlander) (02/01/89)
This past week I started to use some of Common Lisp's advanced array features, sometimes achieving quite unexpected results. I think that I've stumbled upon two bugs in Lucid Common Lisp, but there's a small chance that I might be using displaced offsets incorrectly. I would appreciate it if a CommonLisp guru could tell me whether the former or latter is true. Bug1: (setq *print-circle* t) (setq *print-array* t) (setq a (make-array 100)) (setq b (make-array 3 :displaced-to a :displaced-index-offset 10)) (setq c (make-array 3 :displaced-to a :displaced-index-offset 25)) (setq text (list b c)) Now, when I type "text" to the interpreter, I get the following result: (#1=#(NIL NIL NIL) #1). Yet the (car text) is not eq to (cadr text)! Bug2: (setq u (make-array 400 :element-type 'string-char :fill-pointer t)) (replace u "Common Lisp") (setf (fill-pointer u) 11) (setq y (make-array 10 :element-type 'string-char :fill-pointer t :displaced-to u :displaced-index-offset 6)) (setf (fill-pointer y) 5) (vector-push #\* y) I would expect the asterisk to be placed at position 5 of y, but instead it appears at 5 of u! By the way, I'm running HPCL II A.02.01, a repackaged version of Lucid 2.1 by Hewlett-Packard. The first bug also appears on a Sun 4 running Sun Development Environment 2.1, another repackaged version of Lucid. I didn't get a chance to test out bug #2 on the Sun. David Kurlander djk@columbia.edu
barmar@think.COM (Barry Margolin) (02/01/89)
In article <6150@columbia.edu> djk@vail.cs.columbia.edu (David Kurlander) writes: >This past week I started to use some of Common Lisp's advanced array >features, sometimes achieving quite unexpected results. I think that >I've stumbled upon two bugs in Lucid Common Lisp, but there's a small >chance that I might be using displaced offsets incorrectly. I would >appreciate it if a CommonLisp guru could tell me whether the former or >latter is true. I think your examples were fine, and that Lucid is in error. I also tried both your examples on a Symbolics 3640, and it produced the results I expected. Here's another one that I noticed while trying your second example: (setq u (make-array 20 :element-type 'string-char :fill-pointer t) y (make-array 5 :element-type 'string-char :displaced-to u :displaced-index-offset 6 :fill-pointer t) *print-array* t *print-circle* t) (replace u "Common Lisp") (setf (fill-pointer u) 11) (list y u) => (#1=" Lisp" "Common Lisp") (list u y) => ("Common Lisp" #1=" Lisp") This is mostly just weird, since it doesn't actually produce any incorrect results. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar
news@rocksanne.UUCP (user) (02/04/89)
Your code works under Sun Common Lisp 3.0 on both Sun3 and Sun4 machines running SunOS 4.0: > (setq *print-circle* t) T > (setq *print-array* t) T > (setq a (make-array 100)) #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NI L NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NI L NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NI L NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NI L NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NI L) > (setq b (make-array 3 :displaced-to a :displaced-index-offset 10)) #(NIL NIL NIL) > (setq c (make-array 3 :displaced-to a :displaced-index-offset 25)) #(NIL NIL NIL) > (setq test (list b c)) (#(NIL NIL NIL) #(NIL NIL NIL)) > test (#(NIL NIL NIL) #(NIL NIL NIL)) > -- Jim Mayer Member Research Staff Systems Sciences Laboratory Xerox Webster Research Center 800 Phillips Road, 0128-29E Webster, New York 14580 Phone: (716) 422-9407 EMail: mayer.wbst128@xerox.com (James L Mayer:wbst128:Xerox)