bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] accept null selector for respondsTo...


From: Willem Rein Oudshoorn
Subject: [PATCH] accept null selector for respondsTo...
Date: 15 Feb 2003 10:41:58 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Hm, this might be a little controversial.
At the moment the two methods

        +instancesRespondToSelector:  and -respondsToSelector:

will raise an exception when passed a NULL selector.
I prefer that it returns NO in these circumstances.  

First, let me confess that I do not know the behaviour on other systems.
But in as a general rule I think that querying methods like:

 Is the system to be able to do XXX?

Should never throw an exception.   The answer is either YES or NO.

I think exceptions should be throw when during a request like:

 Count number of lines in file with name "YYY"

some error occur.  

The difference is that in the second case the error interrupts
the normal flow of events.  While in the first case
it does not add anything except for extra code to catch
the potential exception.


Wim Oudshoorn.

ChangeLog
---------

2003-02-15  Willem Rein Oudshoorn  <woudshoo@xs4all.nl>

        * Source/NSObject.m ([NSObject +instancesRespondToSelector:]): return 
NO for null selector
        instead of raising an exception
        ([NSObject -respondsToSelector:]): return NO for null selector instead 
of raising an exception

Attachment: txtyRvx8fAIET.txt
Description: NSObject patch, do not throw exception


reply via email to

[Prev in Thread] Current Thread [Next in Thread]