[comp.sys.mac.hypercard] Garbage collection in XCMDs

hsd@uvacs.cs.Virginia.EDU (Harry S. Delugach) (10/31/88)

I am a beginner at creating XCMDs in LSC 3.0. I am implementing a few
of my choice Home stack interpreted functions. I am still learning simple
string manipulation; how to allocate enough space for the return string, etc.
Each time my XFCN is called, I allocate a new Handle for a return value, 
which I then fill up with a zero-terminated string. My question is: how does
that handle ever get disposed of? If I dispose of it before exiting the
XFCN, that just throws away my return value. Is there a way to mark the
handle for later purging?
-- 
                              Harry S. Delugach   
Dept. of Computer Science, Univ. of Virginia, Charlottesville, VA 22901  U.S.A.
        INTERNET: hsd@cs.virginia.edu       BITNET: hsd2x@virginia
        UUCP: ..!uunet!virginia!uvacs!hsd   CIS: 72727,2363

dan@Apple.COM (Dan Allen) (11/01/88)

In article <2795@uvacs.cs.Virginia.EDU> hsd@uvacs.cs.Virginia.EDU (Harry S. Delugach) writes:
>I am a beginner at creating XCMDs in LSC 3.0. I am implementing a few
>of my choice Home stack interpreted functions. I am still learning simple
>string manipulation; how to allocate enough space for the return string, etc.
>Each time my XFCN is called, I allocate a new Handle for a return value, 
>which I then fill up with a zero-terminated string. My question is: how does
>that handle ever get disposed of? If I dispose of it before exiting the
>XFCN, that just throws away my return value. Is there a way to mark the
>handle for later purging?

An excellent question indeed.  The good news is that you need not do
anything: HyperTalk automatically disposes of the handle that you pass
back as the function result for XFCNs!

Dan Allen
Software Explorer
Apple Computer