Contents (package MULK.OBJECTIVE-CL)


Function DEFINE-RETURNS-BOOLEAN-EXCEPTION

Purpose:

Define an exception to the rule that char means BOOL as a method return type.

Syntax:

define-returns-boolean-exception selector-designator

Arguments and Values:

selector-designator --- a selector designator.

Description:

Normally, Objective-C treats method return values that are nominally of type char as booleans and converts them to either t or nil depending on whether they are zerop. define-returns-boolean-exception directs Objective-CL to treat char values returned by methods named by selector-designator as numbers instead.

undefine-returns-boolean-exception restores the default behaviour.

Examples:

(define-returns-boolean-exception "charValue")  
(define-returns-boolean-exception "characterAtIndex:")  
 

Rationale:

The Objective-C runtime offers no way of distinguishing booleans from chars, even though Foundation defines a BOOL type. In the vast majority of cases, char therefore actually means BOOL, but the NSString class, for one, wouldn't always agree with that sentiment, so the only sane way of handling both booleans and actual char values is to determine the intentional type by method selector.

See also:

undefine-returns-boolean-exception