[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
with-pointers vs. with-macptrs
- Subject: with-pointers vs. with-macptrs
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Tue, 13 Jul 1993 17:10:58 -0500
At 2:54 PM 7/13/93 -0500, Terrance Paul McCartney wrote:
>Does anyone know the difference between "with-pointers" and "with-macptrs"?
>I am developing GWorld intensive software, and some of the examples that I
>have seen use both of these. However, "with-macptrs" is not described in
>the manual. Is one more stable than the other?
>
>- Paul
WITH-MACPTRS & WITH-POINTERS are entirely different.
WITH-MACPTRS is basically the same as LET except that it expects
all of the values to be MACPTRs and arranges for them to all have
dynamic-extent:
? (pprint (macroexpand '(with-macptrs ((x (foo))))))
(LET* ((X (%SETF-MACPTR (%NULL-PTR) (FOO))))
(DECLARE (DYNAMIC-EXTENT X))
(DECLARE (TYPE MACPTR X)))
?
WITH-POINTERS locks and dereferences any values which are HANDLEP
during the execution of its body:
? (pprint (macroexpand '(with-pointers ((x (foo))))))
(LET ((#:G52 (FOO)) #:G51)
(DECLARE (DYNAMIC-EXTENT #:G52))
(UNWIND-PROTECT
(WITH-MACPTRS (X) (SETQ #:G51 (CCL::%THING-POINTER #:G52 0 X)) (PROGN))
(WHEN #:G51 (REQUIRE-TRAP TRAPS::_HUNLOCK #:G51))))
; %thing-pointer is an internal MCL function.
(defun %thing-pointer (pointer offset locked-ptr)
(if (macptrp pointer)
(let ((unlock-ptr nil))
(if (handlep pointer)
(progn
(unless (handle-locked-p pointer)
(setq unlock-ptr pointer)
(#_HLock :errchk pointer))
(%setf-macptr locked-ptr (%get-ptr pointer))
(%strip-address locked-ptr))
(%setf-macptr locked-ptr pointer))
(%incf-ptr locked-ptr offset)
unlock-ptr)
(report-bad-arg pointer '(satisfies macptrp))))