gnustep-dev
[Top][All Lists]
Advanced

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

Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?)


From: Pascal J . Bourguignon
Subject: Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?)
Date: Mon, 9 Feb 2004 09:08:44 +0100

Kazunobu Kuriyama writes:
> Don't attribute it to C programmers. Sane C programmers don't (want to,
> at least) do anything like above.  Apart from the insane, they never try
> to devise a boolen type by themselves once they know the language well,
> though they prefer defining convenience macros such as #define FALSE (0)
> and #define TRUE (1) in their header file.  C99?  They cleverly leave
> that type to the compiler!  We should know this makes a huge difference.
> 
> Apart from their being actually clever or not, it's responsibility for
> Objective C how to define BOOL.  The fault lies only in the fact that BOOL
> has not been made a built-in Objective C type so far (the spec defines it
> as if it were, not explicitly stated like this though).  Without having
> compilers exactly know the meaning of boolean, what can we expect them to
> do with it?  They are only told BOOL is a kind of short integer!  Wrong
> usage of BOOL must attribute to careless ObjC programmers, neither C
> programmers nor compilers.  IOW, that's our problem.

Sorry, I can't resist:

       @interface BOOL
       {
          unsigned char _private;
       }
           +(id)yes;
           +(id)no;
           -(void)ifYes:(void(*)(void))thenFun;
           -(void)ifNo:(void(*)(void))elseFun;
           -(void)ifYes:(void(*)(void))thenFun ifNo:(void(*))elseFun;
           -(int)isYes;
       @end

       @interface BOOL(sloppy)
           +(id)boolFromCInt:(int)value;
           +(id)boolFromCShort:(short)value;
           +(id)boolFromCChar:(char)value;
           +(id)boolFromCPointer:(void*)value;
       @end

(just to make it an Objective-C problem instead of a C problem ;-).
 
> (I'm not saying BOOL should be a built-in; this is another issue and I don't
> want to discuss it here.)

-- 
__Pascal_Bourguignon__                     http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he doesn't
want merely because you think it would be good for him.--Robert Heinlein
http://www.theadvocates.org/




reply via email to

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