[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

file-compile problem/question



I am quite confused by the following difference in behavior I
experience between interpreted and compiled AKCL. Maybe somebody can
tell me whether this is a bug in my thinking or in KCL.

I define the object tree to be a 3-tuple of things: an atom, a
structure, and a list. The definitions can be seen below the following
transcript. I define a simple function to test for tree-hood:

(defun is-treep(tree)
  (and (listp tree)
       (eq (length tree) 3)
       (attribute-p (tree-attribute tree))))

make-tree is the constructor for an empty tree. 

Watch the following transcript:

AKCL (Austin Kyoto Common Lisp)  Version(1.605) Thu Nov 14 17:08:26 CST 1991
Contains Enhancements by W. Schelter

>(load "/home/mousetrap/Source/lisp/r1.23/Other/test.comp.lsp")
(load "/home/mousetrap/Source/lisp/r1.23/Other/test.comp.lsp")
Loading /home/mousetrap/Source/lisp/r1.23/Other/test.comp.lsp
Finished loading /home/mousetrap/Source/lisp/r1.23/Other/test.comp.lsp
T

>(setf x (make-tree))           ;;; set x to the empty tree
(EMPTY-TREE
    NIL NIL)

>(is-treep x)                   ;;; the empty tree is a tree
T                               ;;; in interpreted mode

>(load "/home/mousetrap/Source/lisp/r1.23/Other/test.comp.o")
Loading /home/mousetrap/Source/lisp/r1.23/Other/test.comp.o
start address -T 24644c Finished loading /home/mousetrap/Source/lisp/r1.23/Other/test.comp.o
608

>(setf x (make-tree))           ;;; x is again the empty tree
(EMPTY-TREE
    NIL NIL)

>(is-treep x)                   ;;; however, in compiled mode it 
NIL                             ;;; is not a tree

>(and
  (listp x) (eq (length x) 3) (attribute-p (tree-attribute x)))
T                               ;;; evaluating the body of is-treep
                                ;;; yields T, surprisingly enough

>(bye)
Bye.

The compiled file was generated using (compile-file ...); however, lc
does the same thing. 

My system runs on Sun3-80 und 4.0.1 OS; this happens in both 1.602 and
1.605. 

Any ideas?

Thanks, Thomas

P.S. The definitions used above:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; internal tree representation
;;;
;;; Trees are represented internally as 3 tuples of type 
;;; atom x attribute-type x list
;;; $1 indicates the grammatical type of the tree
;;; $2 is a structure holding attributes: type, parent, info, and attr
;;; $3 is the list of children of the tree

;;  definition of the attribute structure

(defstruct 
  (attribute (:print-function (lambda (x y z)
				(princ (attribute-type x) y))))
  (type nil) (parent nil) (info nil) (attr nil))

(defun tree-attribute(tr)
  (cadr tr))

(defun make-tree()
  (list 'empty-tree (make-attribute) nil))

;; type test

(defun is-treep(tree)
  (and (listp tree)
       (eq (length tree) 3)
       (attribute-p (tree-attribute tree))))