On 1/18/07, David Chisnall <[EMAIL PROTECTED]> wrote:
I spent a little time talking to C++ people recently (sorry), and one
criticism they had of Objective-C was the lack of a way of allocating
objects on the stack.  Since then, I have been looking at NSZone a
bit, and it occurred to me that we could have something equivalent if
we created an NSZone in a global somewhere that didn't free
automatically and was only valid for the duration of the run loop.

Like the default NSAutoreleasePool, it would have to be created at
the start of each run loop, and destroyed at the end.  Any objects
put on it that were still valid at the end would (from what I've
read) automatically be copied into the default zone when the 'stack
zone' was recycled.

This would give us a mechanism for very quickly creating objects that
have a very short lifecycle.  Is it interesting?  If so, is there a
way of registering a method or function to be called at the start and
end of the run loop, or would it require modification of the run-loop
code itself?

You can use GSRunLoopWatcher to watch over a pollUntil: start.
(and addition one-time performer to detect the end of the loop)
But that would fail to detect the run loop that was triggered within
limitDateForMode: that, in GNUstep's implementation, dispatch
timer. In an unofficial fork called Coincide it would allow that, and cheaper,
since it allow source to set C callbacks before and after each loop triggering
and not limited to acceptInputForMode:untilDate:

But I still don't see why we want this, I guess I still don't understand
your suggestion. But if I were, I'd just allocate the object on stack
using a macro that create a struct  [EMAIL PROTECTED](SomeObject)} as a zone 
along
with an autorelease pool p, allocate an autorelease SomeObject in that,
and you need a RELEASE(p); at the end of scope.

But then, I still don't see why we want that. The nature of languages
are different and I think it just shouldn't be programmed that way.


PS. Shouldn't this be discussed on GNUstep or Obj-C?


   _----_     Banlu Kemiyatorn
 /   /\   \   Free Software Yogi
|   /  \   |  -_-~-_-~-_-~-_-~-_-~-_-~-_-~-_
|  /----\  |  QSToRAD, Qing  Shan Tian Xia
 \/      \/   136 Nivesana 7, Jangwattana 14
  QingShan    Laksi, Bangkok, Thailand 10210

_______________________________________________
Etoile-dev mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-dev

Reply via email to