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


In article <9110150605.AA16701@MEDG> psz@lcs.mit.edu writes:

   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. 

There are two reasons: 

1) With-rectangle-arg is more flexible than your expansion. You can
pass a rectangle, or pass two points or pass 4 coordinates, and the
form creates the rectangle using what you've given it.

2) The macro, and in fact the whole of quickdraw.lisp is not meant to
be particularly efficient. If you want efficiency, you should use the
direct trap calls, and (declare (optimize (speed 3) (safety 0))). By
writing the macro as a call, code space is saved, since the whole of
the expansion is just compiled once., a common strategy for non time
critical, frequently used macro expansions.