Callbacks vs. GC
Todd Fleming
todd at flemingcnc.com
Sun Jan 9 01:08:33 PST 2005
Ok, say I want to just pass a signal with the appropriate window handle
to Slate, and have Slate handle all the details. The procedure that
handles the details is a block; I'll call it block A. How do I pass the
Windows message to Slate? I create a Lexical Context and invoke the
interpreter with block A. How do I get block A? I have to store a
pointer to it somewhere.
The problem with the root stack is that it's, well, a stack. Slate calls
a C function, which stores the pointer to the block. The C function then
calls markStackPush and returns. Problem: another function calls
markStackPop to clean up after itself and my entry is gone. My pointer
no longer gets updated when the GC moves the block around.
Todd
Lee Salzman wrote:
>You are looking at this the wrong way. You don't need to prevent the
>object in question from moving. You need the reference to the object to
>be updated to the new location. Coincidentally, there is already a
>mechanism in place for this: the root stack.
>
>Then again, I don't even really see a specific need for any of this,
>given that you could just pass a signal with the appropriate window
>handle to Slate, and let it handle all the details from there.
>
>Overengineering is evil.
>
>Lee
>
>
More information about the Slate
mailing list