Re: Why is [nil aMessage] a no-op?
Re: Why is [nil aMessage] a no-op?
- Subject: Re: Why is [nil aMessage] a no-op?
- From: Graham Cox <email@hidden>
- Date: Fri, 18 Apr 2008 11:19:12 +1000
On 18 Apr 2008, at 8:42 am, Adam P Jenkins wrote:
trying to invoke a method on whatever their equivalent of nil is
produces a runtime error of some sort.
Actually in C++ it produces a solid, good old fashioned crash (I don't
know about the others).
This isn't good - it means you have to check every single return value
and pointer for nil before you can use it - code ends up littered with
thousands of such checks which mostly don't contribute anything to the
code except stopping it falling off the rails in unusual circumstances.
Tracking down bugs when a message to nil is simply swallowed is
sometimes a pain, but I much prefer it to a) having to add all these
mostly redundant checks, and b) having my program crash hard if I
overlooked something (best will in the world and all that), instead of
just carrying on probably with some very minor glitch. As an end user,
what would you prefer? Remember the bad old days when Mac OS 7, 8 or 9
(or Windows 3, 95, 98 come to that) would be crashing all the time for
the most minor transgression? - end users hate that. Programmers might
prefer to be alerted to such problems by a crash, but computers aren't
in fact FOR programmers, they are for users to do things with.
Opinions will vary however ;-)
------
S.O.S.
_______________________________________________
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