Understanding reference count ownership
Clark Cox
clarkcox3 at gmail.com
Sat May 10 11:36:07 PDT 2008
On Sat, May 10, 2008 at 8:20 AM, Christiaan Hofman <cmhofman at gmail.com> wrote:
>
> On 8 May 2008, at 7:16 PM, Sherm Pendley wrote:
>
>> On Thu, May 8, 2008 at 12:48 PM, Christiaan Hofman <cmhofman at gmail.com>
>> wrote:
>>
>> On 8 May 2008, at 6:28 PM, Sherm Pendley wrote:
>>
>>> On Thu, May 8, 2008 at 12:09 PM, Christiaan Hofman <cmhofman at gmail.com>
>>> wrote:
>>>
>>> On 8 May 2008, at 5:50 PM, Sherm Pendley wrote:
>>>>
>>>> On Thu, May 8, 2008 at 11:16 AM, Christiaan Hofman <cmhofman at gmail.com>
>>>> wrote:
>>>>
>>>> E.g. initWithObjects:copyItems:. I couldn't find it in the ownership
>>>> management docs, nor in the description of the method itself.
>>>>
>>>> There's no special mention in the method docs, because none is needed -
>>>> the general rules apply to this method as-is.
>>>
>>> The sentence I linked to and mmalc quoted clearly says 'contains "copy"',
>>> and this method name obviously contains the word "copy".
>>>
>>> The linked-to sentence says "if you create it using a method whose name
>>> begins with "alloc" or "new" or contains "copy"". You created the array
>>> object with +alloc, and then sent it an -initWithObjects:copyItems.
>>
>> That depends on what "create" means.
>>
>> Spare me. This isn't politics, and you aren't Bill Clinton. You know
>> perfectly well what create means, and you know perfectly well that sending a
>> message to an existing object does not create the object.
>
> Apologies, but I have to respond to this.
>
> Seriously, I am not Bill Clinton, and I do *not* know what "create" means in
> this sentence.
It is the simple, English, meaning of the word "create". Nothing more,
nothing less:
create |kriˈeɪt|
verb [ trans. ]
bring (something) into existence
> And I know perfectly well that sending a message to an
> existing object *can* create an object: -copy generally does, and I happen
> to know that this particular initializer *does* create a new object to
> replace the receiver (which is a temporary object). But those are
> implementation details, and implementation details should not matter.
> Personally, I'd say that +array creates a new object.
Full stop; +[NSArray array] creates an object. It brings an array into
existence.
> However the docs say it doesn't.
It says no such thing, it only says that, since "array" does not start
with "new" or "alloc", nor does it contain the word copy, you are nor
responsible for releasing it.
>> Anyway, this discussion is turning too philosophical, it's better to
>> terminate, because we all know exactly what is meant.
>>
>> Precisely my point. Newbies tend to get philosophical, debate about the
>> precise meaning of the word "create," whether a -retain in some other code
>> must be balanced by their own code, etc.
>
> Exactly, that's why the word "create" should not be in this sentence of the
> docs or at least it's meaning should not be decisive about ownership.
It's meaning has zero to do with ownership.
>> It's all this exploring of hypothetical edge cases and exceptions that
>> complicate things; the rules themselves are quite simple and very
>> consistent.
>>
>> sherm--
>
> I disagree. It's exploring the edge cases that clarifies the meaning of
> things and exposes shortcomings in formulation. You agree reading between
> the lines, and I'm saying that the docs should be clear about such a
> fundamental point, without the need to read between the lines or using
> English grammar rules.
The docs are written in English, the reliance on English grammar rules
is implicit.
> I could give you many examples where the rules in the doc would give me the
> wrong answer. But I'll leave that for my bug report.
Please file such a report.
--
Clark S. Cox III
clarkcox3 at gmail.com
More information about the MacOSX-dev
mailing list