Subject: [clisp-list] clue/clx wrt closure (long)

From: John Towler <[email-masked]>
Date: Wed, 20 Sep 2000 12:30:33 -0500

Greetings,

I am trying to build the closure browser.  A prerequisite is building
clue, a port of which is included in the src for closure.  The system
is a sparc-sun-sunos4.1.4.  The current Lisp for this project is CLISP
(2000-03-06).  The provided Makefiles and run scripts did not quite
work as advertised for me.  I am using mkant's defsystem from clocc
instead.  The compilation for CLISP breaks here:

#<BUFFERED FILE-STREAM CHARACTER #P"clue.log" @1>
[19]> (mk:compile-system 'clue)

Compiling file /local/src/lisp/closure-1999-06-06/src/clue/intrinsics.lsp ...
*** - DEFCLASS BASIC-CONTACT: superclass #<STRUCTURE-CLASS WINDOW> should belong to class STANDARD-CLASS

The backtrace is as follows.

1. Break CLUEI[20]> Backtrace

EVAL frame for form 
(CLOS::ENSURE-CLASS 'BASIC-CONTACT :DIRECT-SUPERCLASSES
  (LIST (FIND-CLASS 'WINDOW)) :DIRECT-SLOTS
  (LIST (LIST :NAME 'DISPLAY :READERS '(CONTACT-DISPLAY) :INITARGS '(:DISPLAY))
    (LIST :NAME 'PARENT :READERS '(CONTACT-PARENT) :INITARGS '(:PARENT))
    (LIST :NAME 'NAME :READERS '(CONTACT-NAME) :INITARGS '(:NAME) :INITER
      (CONS 'NIL NIL) :TYPE '(OR NULL SYMBOL)
    )
    (LIST :NAME 'CALLBACKS :READERS '(CONTACT-CALLBACKS) :INITARGS
      '(:CALLBACKS) :INITER (CONS 'NIL NIL) :TYPE '(OR NULL LIST)
    )
    (LIST :NAME 'EVENT-TRANSLATIONS :INITARGS '(:EVENT-TRANSLATIONS) :INITER
      (CONS 'NIL NIL) :TYPE '(OR NULL LIST)
    )
    (LIST :NAME 'EVENT-MASK :READERS '(CONTACT-EVENT-MASK) :INITARGS
      '(:EVENT-MASK) :INITER (CONS 'NIL NIL) :TYPE '(OR NULL MASK32)
    )
    (LIST :NAME 'STATE :READERS '(CONTACT-STATE) :INITARGS '(:STATE) :INITER
      (CONS 'NIL NIL) :TYPE '(OR NULL (MEMBER :WITHDRAWN :MANAGED :MAPPED))
    )
    (LIST :NAME 'SENSITIVE :READERS '(CONTACT-SENSITIVE) :INITARGS
      '(:SENSITIVE) :INITER (CONS 'NIL NIL) :TYPE '(OR NULL (MEMBER :OFF :ON))
    )
    (LIST :NAME 'X :READERS '(CONTACT-X) :INITARGS '(:X) :INITER
      (CONS 'NIL NIL) :TYPE '(OR NULL INT16)
    )
    (LIST :NAME 'Y :READERS '(CONTACT-Y) :INITARGS '(:Y) :INITER
      (CONS 'NIL NIL) :TYPE '(OR NULL INT16)
    )
    (LIST :NAME 'WIDTH :READERS '(CONTACT-WIDTH) :INITARGS '(:WIDTH) :INITER
      (CONS 'NIL NIL) :TYPE '(OR NULL CARD16)
    )
    (LIST :NAME 'HEIGHT :READERS '(CONTACT-HEIGHT) :INITARGS '(:HEIGHT) :INITER
      (CONS 'NIL NIL) :TYPE '(OR NULL CARD16)
    )
    (LIST :NAME 'BORDER-WIDTH :READERS '(CONTACT-BORDER-WIDTH) :INITARGS
      '(:BORDER-WIDTH) :INITER (CONS 'NIL NIL) :TYPE '(OR NULL CARD16)
    )
    (LIST :NAME 'INITIALIZATION :TYPE '(OR (MEMBER :DESTROY) LIST))
    (LIST :NAME 'COMPRESS-MOTION :READERS '(CONTACT-COMPRESS-MOTION)
      :ALLOCATION :CLASS :INITER (CONS 'NIL :ON) :TYPE '(MEMBER :OFF :ON)
    )
    (LIST :NAME 'COMPRESS-EXPOSURES :READERS '(CONTACT-COMPRESS-EXPOSURES)
      :ALLOCATION :CLASS :INITER (CONS 'NIL :OFF) :TYPE '(MEMBER :OFF :ON)
  ) )
  :DOCUMENTATION '"Basic contact using parent's window"
)
EVAL frame for form 
(PROGN
  (CLOS::ENSURE-CLASS 'BASIC-CONTACT :DIRECT-SUPERCLASSES
    (LIST (FIND-CLASS 'WINDOW)) :DIRECT-SLOTS
    (LIST
      (LIST :NAME 'DISPLAY :READERS '(CONTACT-DISPLAY) :INITARGS '(:DISPLAY))
      (LIST :NAME 'PARENT :READERS '(CONTACT-PARENT) :INITARGS '(:PARENT))
      (LIST :NAME 'NAME :READERS '(CONTACT-NAME) :INITARGS '(:NAME) :INITER
        (CONS 'NIL NIL) :TYPE '(OR NULL SYMBOL)
      )
      (LIST :NAME 'CALLBACKS :READERS '(CONTACT-CALLBACKS) :INITARGS
        '(:CALLBACKS) :INITER (CONS 'NIL NIL) :TYPE '(OR NULL LIST)
      )
      (LIST :NAME 'EVENT-TRANSLATIONS :INITARGS '(:EVENT-TRANSLATIONS) :INITER
        (CONS 'NIL NIL) :TYPE '(OR NULL LIST)
      )
      (LIST :NAME 'EVENT-MASK :READERS '(CONTACT-EVENT-MASK) :INITARGS
        '(:EVENT-MASK) :INITER (CONS 'NIL NIL) :TYPE '(OR NULL MASK32)
      )
      (LIST :NAME 'STATE :READERS '(CONTACT-STATE) :INITARGS '(:STATE) :INITER
        (CONS 'NIL NIL) :TYPE '(OR NULL (MEMBER :WITHDRAWN :MANAGED :MAPPED))
      )
      (LIST :NAME 'SENSITIVE :READERS '(CONTACT-SENSITIVE) :INITARGS
        '(:SENSITIVE) :INITER (CONS 'NIL NIL) :TYPE
        '(OR NULL (MEMBER :OFF :ON))
      )
      (LIST :NAME 'X :READERS '(CONTACT-X) :INITARGS '(:X) :INITER
        (CONS 'NIL NIL) :TYPE '(OR NULL INT16)
      )
      (LIST :NAME 'Y :READERS '(CONTACT-Y) :INITARGS '(:Y) :INITER
        (CONS 'NIL NIL) :TYPE '(OR NULL INT16)
      )
      (LIST :NAME 'WIDTH :READERS '(CONTACT-WIDTH) :INITARGS '(:WIDTH) :INITER
        (CONS 'NIL NIL) :TYPE '(OR NULL CARD16)
      )
      (LIST :NAME 'HEIGHT :READERS '(CONTACT-HEIGHT) :INITARGS '(:HEIGHT)
        :INITER (CONS 'NIL NIL) :TYPE '(OR NULL CARD16)
      )
      (LIST :NAME 'BORDER-WIDTH :READERS '(CONTACT-BORDER-WIDTH) :INITARGS
        '(:BORDER-WIDTH) :INITER (CONS 'NIL NIL) :TYPE '(OR NULL CARD16)
      )
      (LIST :NAME 'INITIALIZATION :TYPE '(OR (MEMBER :DESTROY) LIST))
      (LIST :NAME 'COMPRESS-MOTION :READERS '(CONTACT-COMPRESS-MOTION)
        :ALLOCATION :CLASS :INITER (CONS 'NIL :ON) :TYPE '(MEMBER :OFF :ON)
      )
      (LIST :NAME 'COMPRESS-EXPOSURES :READERS '(CONTACT-COMPRESS-EXPOSURES)
        :ALLOCATION :CLASS :INITER (CONS 'NIL :OFF) :TYPE '(MEMBER :OFF :ON)
    ) )
    :DOCUMENTATION '"Basic contact using parent's window"
) )
EVAL frame for form (MAKE:COMPILE-SYSTEM 'USER::CLUE)

The relevant form in the immediate source seems to be:

;; from clue/intrinsics.lsp

;;; Basic CONTACT class

(defcontact basic-contact (xlib:window)
  ((display            :initarg :display
		       :reader contact-display)
   
   (parent             :initarg :parent
		       :reader contact-parent) ; setf defined below
   
   (name               :type symbol
		       :initarg :name
		       :initform :unnamed
		       :reader contact-name)
   
   (callbacks          :type list
		       :reader contact-callbacks
		       :initform nil)
   
   (event-translations :type list
		       :initform nil)
   
   (event-mask         :type mask32
		       :initform #.(make-event-mask :exposure)
		       :reader   contact-event-mask) ; setf defined below
   
   (state              :initform :mapped
		       :type (member :withdrawn :managed :mapped)
		       :reader contact-state) ; setf defined below
   
   (sensitive          :initform :on
		       :type (member :off :on)
		       :reader contact-sensitive) ; setf defined below
   
   (x                  :type int16
		       :initform 0
		       :reader contact-x)
   
   (y                  :type int16
		       :initform 0
		       :reader contact-y)
   
   (width              :type card16
		       :initform 0
		       :reader contact-width)
   
   (height             :type card16
		       :initform 0
		       :reader contact-height)
   
   (border-width       :type card16
		       :initform 1
		       :reader contact-border-width)

   (initialization :type (or (member :destroy) list)) ; internal slot for window initialization and destruction
   
   ;; Class allocated slots
   (compress-motion    :initform :on :type (member :off :on)
		       :reader contact-compress-motion
		       :allocation :class)
   
   (compress-exposures :initform :off :type (member :off :on)
		       :reader contact-compress-exposures
		       :allocation :class
		       ))
  (:documentation "Basic contact using parent's window")
  (:resources
   (screen :type (or null card8))	;Selects screen when parent is a display
   ;; Slots
   name
   callbacks
   event-translations
   event-mask
   state
   sensitive
   x y width height border-width
   ))

CLOS is new to me, but it seems that CLISP has read a class defined for
xlib:window elsewhere, for which it wants the direct-superclass of
xlib:window to be standard-class.  Or perhaps merely presumed that it
shoud have, hence the error.  I don't have the results on hand, but
cmucl-18a did not complain about this error, granted they have a pcl
implementation, not a native CLOS. 

A comment in clue/clos-patch.lisp referred to the macro def-clx-class
in clx/depdefs.lsp 
which has a controlling variable *def-clx-class-use-defclass*.  I
changed this so the macro would use defclass, assuming that it would
then resolve the superclasses in the usual way.  This has not worked.

How does one add the direct-superclass that the compiler/reader
wants for DEFCLASS BASIC-CONTACT.

(a) so that I can see if this will work (the local band-aid to make it
					     go),
and

(b) so that clx does the right thing in general
	(find where in the clx code this is defined,
	 and study how to make xlib:window fit into CLOS's preferred
	 standard class hierarchy.)

(b) is the preferred solution, but it might not be immediately
feasible today.  Ideally (a) and (b) would be equivalent.  It seems
that there might be a way to add the needed 
superclass, but I don't yet know what it is (not knowing CLOS).
If someone, perhaps who has been through this before, could point me
in the right direction, that would be appreciated.

			Thanks,
			John R. Towler

---

From: Paolo Amoroso <[email-masked]>
Date: Thu, 21 Sep 2000 17:34:48 +0200

> (2000-03-06).  The provided Makefiles and run scripts did not quite

Which CLX implementation do you use with CLISP to build CLUE for Closure?
MIT CLX or NCLX by Gilbert Baumann? NCLX is known not to work with
CLUE/CLIO. You may try building the system with MIT CLX.

Paolo
-- 
EncyCMUCLopedia * Extensive collection of CMU Common Lisp documentation
http://cvs2.cons.org:8000/cmucl/doc/EncyCMUCLopedia/

---

From: John Towler <[email-masked]>
Date: 24 Sep 2000 14:24:16 -0500

MIT CLX 5.0, 
5.02 compiles but even with a restarted X, complains about .Xauthority
(already generated) to run the $clxtop/demo code. 
I want to get the thing running more quickly for the moment.  

There were an host of declarations in #'read/write-sequence-* along
the lines of 
(defun ...
(declare (type (or null (function (character) t)) transform)
	   #+clx-ansi-common-lisp
	   (dynamic-extent transform)
...
(if transform
    (flet (((card8->char->transform (v)
	       (declare (type card8 v))
		#+clx-ansi-common-lisp
		(declare (dynamic-extent #'card8->char->transform))
	       (funcall transform (card8->char v))))
...]

where the #+clx-ansi-common-lisp (declare ... ) had to be moved up to
precede the (funcall transform ... ).  (Unless they meant something
else and I got it wrong.)  One or two instances of redefining type
boolean as well.  The changes I made are included below.

			John Towler

---

From: Bruno Haible <[email-masked]>
Date: Wed, 27 Sep 2000 14:58:06 +0200 (CEST)

> I want to get the thing running more quickly for the moment.  

Then you might try CMUCL instead of CLISP.

> precede the (funcall transform ... ).

I don't think your patch is correct. For a 'dynamic-extent' declaration to
have an effect here, it should be a "bound declaration" (CLHS term),
which means that it should occur at the beginning of the 'flet' body.

> One or two instances of redefining type
> boolean as well.

I thought this were fixed by the following patch:

    1998-08-01  Bruno Haible  <[email-masked]>

        * clx/mit-clx/package.lsp: Shadow BOOLEAN and don't export it.

What error messages did you see?

> ! (defvar *def-clx-class-use-defclass* #+Genera t #-Genera '(clisp cltl2)
> ! 								

This piece of patch is broken. Neither 'clisp' not 'cltl2' is a type name.

> ! #-(and (or GCL AKCL) (not PCL)) ;; You may remove this line for CLISP with native CLOS.

Why do you add GCL here? It is useless, because GCL has AKCL in its
*features* list.

I agree that CLISP should define XLIB:WINDOW etc. as classes, not
structs, so that CLOSURE works. Can you send a minimal, tested patch
please?

Bruno

---

From: Raymond Toy <[email-masked]>
Date: 06 Oct 2000 10:12:16 -0400

>>>>> "John" == John Towler <[email-masked]> writes:

    John> MIT CLX 5.0, 
    John> 5.02 compiles but even with a restarted X, complains about .Xauthority
    John> (already generated) to run the $clxtop/demo code. 

If this is the stock CLX, I don't think it completely understands
.Xauthority.  If your $DISPLAY is :0.0, .Xauthority has entries
like

<host>/unix:0 MIT-MAGIC-COOKIE-1  <key>

and CLX doesn't know how to interpret this.

The version of CLX in CMUCL has code that understands this.

Ray