[Openmcl-devel] Dynamic or static scope

Taoufik Dachraoui taoufik.dachraoui at wanadoo.fr
Wed Oct 14 23:38:11 PDT 2009


Dear,

In the following code I do not understand why *CONTEXT* is the same  
before (FUNCALL ...)
and within the called function unlike *WIDTH*, *HEIGHT* and *X*

Unlike *CONTEXT*, *X* is 123 before calling the lambda (FUNCALL ..)  
and 456 within the defined lambda. I would like *CONTEXT* to be  
lexically defined as *X*, *WIDTH*

Thank you for your help
Kind regards
Taoufik

(LET* ((*DISPLAY* (XOPENDISPLAY ":0.0"))
        (*SCREEN* (XDEFAULTSCREEN *DISPLAY*))
        (*ROOT* (XDEFAULTROOTWINDOW *DISPLAY*))
        (*VISUAL* (XDEFAULTVISUAL *DISPLAY* *SCREEN*))
        (*DEPTH* (XDEFAULTDEPTH *DISPLAY* *SCREEN*))
        (*WHITEPIXEL* (XWHITEPIXEL *DISPLAY* *SCREEN*))
        (*ATTRIBUTES*
         (LIST :X
               100
               :Y
               100
               :WIDTH
               400
               :HEIGHT
               400
               :BACKGROUND-PIXEL
               *WHITEPIXEL*
               :EVENT-MASK
               (LOGIOR BUTTONPRESSMASK)))
        (*WINDOW* (MY-CREATE-WINDOW *DISPLAY* *ROOT* *VISUAL*  
*ATTRIBUTES*))
        (*WIDTH* (GETATTR :WIDTH *ATTRIBUTES*))
        (*HEIGHT* (GETATTR :HEIGHT *ATTRIBUTES*))
        (*CONTEXT*
         (MY-CREATE-CONTEXT
           *DISPLAY*
           *VISUAL*
           *WINDOW*
           *ROOT*
           *WIDTH*
           *HEIGHT*))
        (*PARENT* *WINDOW*)
        (*ALL-CONTEXTS* NIL)
        (*EVENT-HANDLERS* NIL)
        (*x* 123))
   (SET-WINDOW-SIZE-HINTS *DISPLAY* *WINDOW* *WIDTH* *WIDTH* *HEIGHT*  
*HEIGHT*)
   (XSTORENAME *DISPLAY* *WINDOW* "Test")
   (XMAPWINDOW *DISPLAY* *WINDOW*)
   (LABELS ((ADD-EVENT-HANDLER (EVENTTYPE HANDLER)
              (PUSH (CONS (CONS EVENTTYPE *WINDOW*) HANDLER) *EVENT- 
HANDLERS*))
            (REFRESH NIL
              (DOLIST (C (REVERSE *ALL-CONTEXTS*))
                (CAIRO_PAINT (XLIB-CONTEXT C)))
              (CAIRO_PAINT (XLIB-CONTEXT *CONTEXT*)))
            (EVENT-LOOP NIL
              (LET ((WM-PROTOCOLS (XINTERNATOM *DISPLAY*  
"WM_PROTOCOLS" 1)))
                (WITH-FOREIGN-OBJECT
                  (XEV :LONG 24)
                  (DO ((GOT-CLOSE-SIGNAL NIL))
                      (GOT-CLOSE-SIGNAL)
                    (XNEXTEVENT *DISPLAY* XEV)
                    (WITH-FOREIGN-SLOTS
                      ((TYPE WINDOW SERIAL) XEV XANYEVENT)
                      (FORMAT T
                              "event ~A serial ~A window ~A *window*  
~A~%"
                              TYPE
                              SERIAL
                              WINDOW
                              *WINDOW*)
                      (COND ((= TYPE CLIENTMESSAGE)
                             (WITH-FOREIGN-SLOTS
                               ((MESSAGE-TYPE DATA0) XEV  
XCLIENTMESSAGEEVENT)
                               (IF (AND (= WINDOW *WINDOW*)
                                        (= MESSAGE-TYPE WM-PROTOCOLS)
                                        (= DATA0 (WM-DELETE-WINDOW  
*CONTEXT*)))
                                   (PROGN (FORMAT T "close application~ 
%")
                                          (SETF GOT-CLOSE-SIGNAL T)))))
                            (T
                             (LET ((E
                                    (ASSOC (CONS TYPE WINDOW)
                                           *EVENT-HANDLERS*
                                           :TEST
                                           'EQUAL)))
                               (FORMAT T
                                       "handle event type=~A  
*context*=~A *width* ~A *height* ~A window ~A *x* ~A~%"
                                       TYPE
                                       *context* *width* *height*  
window *x*)
                               (FORCE-OUTPUT T)
                               (IF (NOT (NULL E)) (FUNCALL (CDR E) XEV))
                               (REFRESH))))))))
              (DOLIST (C (REVERSE *ALL-CONTEXTS*)) (DESTROY-CONTEXT C))
              (XCLOSEDISPLAY *DISPLAY*)))
     (PROGN (LET* ((*ATTRIBUTES*
         (LIST :X
               10
               :Y
               10
               :WIDTH
               100
               :HEIGHT
               100
               :EVENT-MASK
               (LOGIOR BUTTONPRESSMASK BUTTONRELEASEMASK)))
        (*WINDOW* (MY-CREATE-WINDOW *DISPLAY* *PARENT* *VISUAL*  
*ATTRIBUTES*))
        (*WIDTH* (GETATTR :WIDTH *ATTRIBUTES*))
        (*HEIGHT* (GETATTR :HEIGHT *ATTRIBUTES*))
        (*CONTEXT*
         (MY-CREATE-CONTEXT
           *DISPLAY*
           *VISUAL*
           *WINDOW*
           *PARENT*
           *WIDTH*
           *HEIGHT*))
        (*PARENT* *WINDOW*)
        (*x* 456))
   (PUSH *CONTEXT* *ALL-CONTEXTS*)
   (XMAPWINDOW *DISPLAY* *WINDOW*)
   (LABELS ((ADD-EVENT-HANDLER (EVENTTYPE HANDLER)
   	     (format t ">>> *context* ~A *width* ~A *height* ~A~%"  
*context* *width* *height*)
              (PUSH (CONS (CONS EVENTTYPE *WINDOW*) HANDLER) *EVENT- 
HANDLERS*)))
     (PROGN (LET ((COUNT 0) (POSX 0) (POSY 0))
              (ADD-EVENT-HANDLER EXPOSE
               #'(LAMBDA (EVENT)
                   (WITH-FOREIGN-SLOTS
                     ((TYPE WINDOW SERIAL) EVENT XEXPOSEEVENT)
                     (FORMAT T
                             "Expose... *x* ~A context ~A width=~A  
height=~A~%" *x*
                             *CONTEXT*
                             *WIDTH*
                             *HEIGHT*)
                     (SET-SOURCE-RGB 0.5 0.5 0.5)
                     (RECTANGLE 0 0 *WIDTH* *HEIGHT*)
                     (SET-SOURCE-RGB 0 0 0)
                     (FILL-PATH)
                     (MOVE-TO 20 200)
                     (SET-SOURCE-RGB 0.5 0.5 0.5)
                     (INCF COUNT)
                     (SHOW-TEXT (FORMAT NIL "count ~A" COUNT)))))
                   )))))
     (EVENT-LOOP)))

 >>>> output
event 12 serial 131 window 6291458 *window* 6291457
handle event type=12 *context*=#<MY-XLIB-CONTEXT pointer: #<A Foreign  
Pointer #x80D000>, width: 400, height: 400, pixel-based-p: T> *width*  
400 *height* 400 window 6291458 *x* 123
Expose... *x* 456 context #<MY-XLIB-CONTEXT pointer: #<A Foreign  
Pointer #x80D000>, width: 400, height: 400, pixel-based-p: T>  
width=100 height=100
event 33 serial 191 window 6291457 *window* 6291457



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20091015/1e850402/attachment.htm>


More information about the Openmcl-devel mailing list