Re: Constructive Criticism
Re: Constructive Criticism
- Subject: Re: Constructive Criticism
- From: Alastair Houghton <email@hidden>
- Date: Wed, 7 Oct 2009 18:45:15 +0100
On 7 Oct 2009, at 18:19, BJ Homer wrote:
On Wed, Oct 7, 2009 at 10:53 AM, Derek Chesterfield <email@hidden>
wrote:
On 6 Oct 2009, at 22:48, Alastair Houghton <email@hidden
> wrote:
Oh, and since I'm in the dot-syntax-is-evil camp, s/self.year/[self
year]/g in Bill's code :-D :-D
Just an aside, but does either syntax got optimised by the compiler
(GCC or LLVM). Obviously it can't in all cases, but this seems an
obvious case where it could be replaced by an
assignment._______________________________________________
If you replace self.something = @"value" with something = @"value",
Key-Value Observing won't work. So no.
It isn't just about KVO.
self.something = @"value";
is equivalent, as we all know to
[self setSomething:@"value"];
and it's entirely possible for someone to override the -setSomething:
method. Moreover, even if the compiler could see and analyse all of
your source files, it's possible to override methods or even subclass
your class *at runtime*, and so there is no guarantee that the
equivalent to the message (for some putative subclass) would be to do
an assignment.
Obviously technology like KVO and DO relies on these kinds of
abilities in the runtime, and so it will certainly break, but more
mundane things would break also.
Of course, this would be largely obvious if it weren't for the fact
that the dot syntax made it look like an assignment in the first
place. I'm sure I'm not the only person who wished that there had
been a bit more debate with people outside of Apple (e.g. on the
objective-C language list) about this syntax before it was announced.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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