Callbacks vs. GC

Todd Fleming todd at flemingcnc.com
Sun Jan 9 11:15:26 PST 2005


Oops, I did mix up the 2 stacks. Substitute markStackPush with 
rootStackPush and markStackPop with rootStackPop in my email. I still 
have a problem if I try to use it.

Some internal slate function()
{
   markStackPush(...);
   ....
   createWin32Window(block, ...); // This could be several layers deep 
in the call stack
   ....
  markStackPop(1); // Whoops
}

Object* blockForCallback;

createWin32Window(block, ...)
{
  blockForCallback = block;
  markStackPush(&blockForCallback);
  ...
  // doesn't pop; callback needs to know where block moves to.
}

Marshalling many Win32 messages is trivial; the arguments are integers. 
I'll worry about marshalling messages with pointers later. What does 
marshalling have to do with the block moving around?

Todd


Lee Salzman wrote:

>I said the root stack, not the mark stack. You are apparently confusing
>the two.
>
>Also, think marshalling.
>
>Lee
>
>On Sun, Jan 09, 2005 at 04:08:33AM -0500, Todd Fleming wrote:
>  
>
>>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
>>>
>>>
>>>      
>>>
>
>
>
>  
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /archives/slate/attachments/20050109/58ac9a12/attachment.html


More information about the Slate mailing list