Re: Garbage collector vs variable lifetime
Re: Garbage collector vs variable lifetime
- Subject: Re: Garbage collector vs variable lifetime
- From: Antonio Nunes <email@hidden>
- Date: Mon, 9 Jun 2008 12:54:32 +0100
On 9 Jun 2008, at 00:53, Chris Kane wrote:
On 7 Jun 2008, at 09:07, Antonio Nunes wrote:
On 7 Jun 2008, at 06:16, Ken Thomases wrote:
The issue is, how can one know when this technique is necessary?
By proper documentation. As Bill mentioned earlier, the
documentation needs to mention this behaviour. Just as retain/
release, GC has its own caveats, it's own moments where one has to
take special care. This appears to be one of them. If I read Bill's
explanation correctly then once the documentation gets updated and
distributed anyone can know when this technique is necessary (as
long as they know what they're doing, which goes for anything in
programming).
<sarcasm>Oh, yes, it's just that simple.</sarcasm> Even
understanding the potential does not necessarily lead to recognizing
when special action needs to be taken. In amongst the hundred other
things you have to keep in mind as you write a method, there will
also be, "let's see, is this the last use of this object in this 100-
line method? <scroll, scroll> Hmm, yes, it appears so. Let's
see, do I need to take any special actions ...? OK, now what about
this next object ...?" etc. And what about code which already
exists, such as "millions" of lines of Cocoa/ObjC code in the OS
frameworks? Somebody has gone over years of accummulated
"optimized" code with a fine-tooth comb to find such things? I'll
say no more; these are just hypothetical statements pointing out the
shallowness of a "documentation bandaid" approach.
The question was: How _can_ one know: Having this documented enables
people to know this is something to be on the lookout for. Of course
the fact that something is documented doesn't imply that we won't miss
these caveats. We make mistakes all over the place. But we can't look
out for what we don't know. So let me put it like this: documentation
is the first step.
(By the way, and because of the recent flames against Apple's
documentation: I think Apple are doing a great job, and constantly
trying to improve upon what they have to offer.)
It'd be much better if the tools could warn you about such things in
the source code. Or something.
That would indeed be most useful. Or something ;-)
António
-----------------------------------------------------------
Some things have to be believed to be seen.
--Ralph Hodgson
-----------------------------------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden