Re: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS
Re: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS
- Subject: Re: NSDecimalNumber nil parameter to -decimalNumberByAdding: causes Mach exception EXC_BAD_ACCESS
- From: Michael Ash <email@hidden>
- Date: Tue, 14 Apr 2009 00:14:13 -0400
On Mon, Apr 13, 2009 at 5:29 PM, email@hidden
<email@hidden> wrote:
>
> On 13 Apr 2009, at 22:13, Kyle Sluder wrote:
>
>> On Mon, Apr 13, 2009 at 4:47 PM, email@hidden
>> <email@hidden> wrote:
>>>
>>> NSDecimalNumber *n2 = nil;
>>> n1 = [n1 decimalNumberByAdding:n2];
>>
>> You can't assume that nil is a valid argument. So no, the lack of any
>> documentation stating that "passing nil will blow up" is not a bug.
>>
> Whatever way you slice it, bug or not, this is fairly toxic behaviour.
Call it what you like, but it's also extremely common behavior. A
crash due to passing a NULL pointer to where it is not explicitly
allowed is extremely common in C, and Objective-C is just an offshoot
of C. Your attitude should not be that you will only avoid passing nil
to methods which say it's not allowed. On the contrary: unless nil is
*explicitly* allowed, you *must not* pass it. The fact that some
methods explicitly disallow it does not change this fact.
Mike
_______________________________________________
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