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

Useful RfCon

   Date: Wed, 15 Aug 90 10:46:25 -0400
   From: blakem@world.std.com (Blake Meike)

   The story so far: I asked how to save object pointers in
   control refcons, Andrew pointed out that after a garbage collection
   any such pointer would be junk.

   Uh, oh.  Ok, I won't try that.

   Well, the idea was to provide a scroll bar action proc with a way
   of getting in touch with the object that represents it in the Lisp
   world.  I just looked at some other examples of how to do this,
   and to my huge surprise, I found this:

   (defobfun (do-scroll *scroll-bar*) ()

   (defpascal scroll-proc ((my-control :ptr) (partCode :word))

   Why does this work?  Why doesn't scroll-proc have
   to (ask <somebody> (do-scroll))?

   I think it accomplishes what I want to accomplish, but I sure
   blazes don't see why.

   Blake Meike

The answer is that the scroll-proc is passed to _TrackControl from
inside an OBFUN for *scroll-bar*.  Hence, the current object is bound
when the toolbox calls scroll-proc.  Effectively, you're getting
something like this (except the binding of *current-object* is
implicit in the entry to the defobfun):

(defobfun (track-scroll-bar *scroll-bar*) ()
  (let ((*current-object* scroll-bar))
    (declare (special *current-object*))
    (_TrackControl ... :ptr scroll-proc ...)))

(defpascal scroll-proc ((my-control :ptr) (partCode :word))
  (declare (special *current-object*))
  (ask *current-object* (do-scroll)))

Bill St. Clair