Re: self release
Re: self release
- Subject: Re: self release
- From: David Remahl <email@hidden>
- Date: Mon, 12 May 2003 22:53:26 +0200
Danny,
I see your point.
Reversing the order of your points, I believe there was a thread a few
days ago that discussed the usage of "you" as in "you must release".
Clearly the word is ambiguous.
Regarding the point that a thread should release its resources when it
dies...
According to the documentation for NSThread's
-detachThreadSelector:toTarget:withObject:, the thread actually retains
aTarget for the duration of the thread. Therefore, if runInBackground
spins off a thread (as it most likely does), then the object will be
automagically released when the thread completes. No retains, no
ambiguities.
/ Rgds, David
On Monday, May 12, 2003, at 09:53 PM, Danny Swarzman wrote:
I disagree with this! The best way to handle this is a Wolfgang first
stated. Of course there should be comments in the right places.
A factory method to create the object have a comment saying that these
objects are released in the suicide method.
There are two issues involved.
One is that threads should release their resources when they die, not
at
some ambiguous time in the future. This is normal practice for very
good
reasons.
Second is that the proverb "what you retain/alloc you must release" is
bad
English usage. The "you" may be a method, several methods, an object, a
class - everyone understands this differently.
The proverb I propose is "avoid antropomorphism". If you are reading
this,
I assume you are human being. For the present purpose, I consider
myself to
be one.
The proverb for memory usage is "make sure that the count is zero when
the
program is done".
Of course it is best write code so that the person reading it sees that
things are undone in the same part of the source code that they are
done.
-Danny Swarzman
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.