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

Re: Suggestion - rlet with clear

>I wanted to throw out a suggestion for an optional argument to
>the rlet macro which first clears any structures it allocates
>with NewPtr (and before it makes any assignments to the fields).
>I have several cases where I have to manually clear the fields.
>I would try using the ccl::%clear-pointer or ccl::%clear-block but
>there are two problems:
>1) They are undocumented
>2) I then have to add a statemtent to assign each field and lose the
>   convenience of the rlet macro.
>An example might be:
>(rlet ((p :ParamBlockRec :clear t
>          :ioNamePtr volName
>          :ioVRefNum vRefNum))
>  (#_SomeHFSCall pb)
>  (pref pb :ParamBlockRec.ioResult))
>            Jeffrey

MCL already has a feature similar to what you're asking for. It is
undocumented, but I will add it to my list of things that need to
be exported and documented for MCL 2.1. The macro is called
CCL::RLETZ. Its syntax is identical to RLET. The difference is
that it expands into a %STACK-BLOCK form with (... :CLEAR t) specified
for each variable (this is an undocumented feature of %STACK-BLOCK).
The %STACK-BLOCK form compiles into a call to a kernel function that
does the clearing in a tight assembly language loop.

? (pprint
    '(ccl::rletz ((pb :ParamBlockRec
                     :ioNamePtr volName
                     :ioVRefNum vRefNum))
       ;(#_SomeHFSCall pb)
       (pref pb :ParamBlockRec.ioResult))))