Le 18 janv. 07 à 14:59, David Chisnall a écrit :
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.
Do you mean something like?
- methodWithNewRunLoop
{
myStackPool = [[ETStackPool alloc]] init]]
[self aMethod]
[myStackPool release]
}
- aMethod
{
newObject = [[[NSObject alloc] init] stackrelease]
// newObject will be released now on exiting aMethod
}
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.
By 'put on it'… I'm not sure to understand if you talk about
NSAutoreleasePool or a new similar mechanism to allocate object on
stack.
This would give us a mechanism for very quickly creating objects
that have a very short lifecycle. Is it interesting?
I don't really know. Many optimizations will often be available
before switching to such "unusual" object management. Most of object
oriented languages always put objects on the heap, so developers are
inhabited to it.
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?
Not that I know of.
Cheers,
Quentin.
--
Quentin Mathé
[EMAIL PROTECTED]
_______________________________________________
Etoile-dev mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-dev