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

Why is with-rectangle-arg so complicated?

I have been trying to write some efficient quickdraw code and have
tried using the trap level of coding rather than the functions defined
in QuickDraw.lisp.  Perusing those functions, however, I am puzzled
why the often-used (with-rectangle-arg ...) form expands into an
invocation of (call-with-rectangle-arg ...) whose first argument is a
thunk encapsulating the computation.  I would have assumed that
something like

(with-rectangle-arg (r left top right bot)
    (#_EmptyRect r))
(rlet ((r :rect :left left :top top :right right :bottom bot))
  (#_EmptyRect r))

would do just as well.  It seems as if the body would simply be
evaluated within the dynamic scope of r being a record on the stack,
and unless the body stored or returned r, all should be well.  And
surely this would be more efficient when compiled than a call with a
thunk argument which is then funcalled!

Acting on my intuition, I tried writing my own version of
start-picture and get-picture using the above scheme, however, and
they just don't work.  I assume I'm missing something either
fundamental or subtle.  Could someone give me a hint?  Thanks.  
--Pete Sz.

P.S.  This is in 2.0 beta.