Re: Using properties (was Re: Outlets / IBOutlet declarations)

2008-11-20 Thread Michael Ash
On Wed, Nov 19, 2008 at 11:53 PM, mmalcolm crawford <[EMAIL PROTECTED]> wrote:
>
> On Nov 19, 2008, at 8:40 PM, Michael Ash wrote:
>
>> On Wed, Nov 19, 2008 at 5:41 PM, mmalcolm crawford <[EMAIL PROTECTED]>
>> wrote:
>>>
>>> On Nov 19, 2008, at 2:29 PM, Michael Ash wrote:

 Because there's essentially no good way to dispose of properties given
 the way that they're implemented.
>>>
>>> I'm not sure why this is the case?
>>> You send a release message to instance variables for which there is a
>>> corresponding retain or copy property.
>>
>> This does not qualify as "good" in my book. A fundamental of good
>> programming is "once and only once". You've now described the
>> semantics of these properties in two different places in your code
>> and, worse, one of those places is implicit rather than explicit.
>>
> I'm not sure what you mean here?
> There is only one place where the semantics are described: In the property
> declaration.
> Whether you release or not in dealloc is a corollary of that declaration.

Well, I think this is just a question of wording. It's true that it's
only described in one place, but you have to get it right in two
places. Whenever you have a situation like that and the compiler can't
check it (like in this case), then you have a potential to get mixed
up, especially if you make changes later on. It would be fairly easy
for the properties mechanism to provide a way to use the @property
declaration to generate the correct -dealloc behavior. In fact, there
is one, "self.whateverProperty = nil", it's just that this has other
unfortunate side effects. An alternate version with no side effects
would remove this deficiency.

> In which case we may be mostly in violet (sic) agreement.
> I obviously see significant benefits to using properties, and agree that
> their utility *might* be enhanced if they could also handle dealloc.  I got
> the impression that others here were suggesting that they provide little or
> no benefit at all...

Yeah, I didn't get that impression myself. It's just a bit painful to
see such a construct when a small addition to it would have made a
significant improvement.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Using properties (was Re: Outlets / IBOutlet declarations)

2008-11-19 Thread mmalcolm crawford


On Nov 19, 2008, at 8:40 PM, Michael Ash wrote:

On Wed, Nov 19, 2008 at 5:41 PM, mmalcolm crawford <[EMAIL PROTECTED] 
> wrote:


On Nov 19, 2008, at 2:29 PM, Michael Ash wrote:
Because there's essentially no good way to dispose of properties  
given

the way that they're implemented.

I'm not sure why this is the case?
You send a release message to instance variables for which there is a
corresponding retain or copy property.

This does not qualify as "good" in my book. A fundamental of good
programming is "once and only once". You've now described the
semantics of these properties in two different places in your code
and, worse, one of those places is implicit rather than explicit.


I'm not sure what you mean here?
There is only one place where the semantics are described: In the  
property declaration.
Whether you release or not in dealloc is a corollary of that  
declaration.



But you have the same problem without properties.
Except that it's worse; you could change the implementation of an  
accessor

method (to assign rather than retain, for example), and you'd have no
cross-check to make sure you then did the right thing in dealloc.
With properties, you have a clear set of statements that publicly  
declare
what are the memory management semantics, and you can cross-check  
them with

your dealloc method.

This is true but I don't really see the point. I never said properties
were worse than manual accessors, just that this omission really hurts
their utility.


In which case we may be mostly in violet (sic) agreement.
I obviously see significant benefits to using properties, and agree  
that their utility *might* be enhanced if they could also handle  
dealloc.  I got the impression that others here were suggesting that  
they provide little or no benefit at all...


mmalc

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]