discuss-gnustep
[Top][All Lists]
Advanced

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

Re: [gnustep/libs-gui] * Source/NSWindow.m (-makeFirstResponder, -sendEv


From: Fred Kiefer
Subject: Re: [gnustep/libs-gui] * Source/NSWindow.m (-makeFirstResponder, -sendEvent:): Correct (be12d7b)
Date: Fri, 15 May 2020 09:30:09 +0200

> Am 15.05.2020 um 08:28 schrieb Johannes Brakensiek <notifications@github.com>:
> 
> I'm new to Objective C, so this is just a question:
> 
> In the NY Times Objective C style guide I am reading:
> 
> Values MUST NOT be compared directly to YES, because YES is defined as 1, and 
> a BOOL in Objective-C is a CHAR type that is 8 bits long (so a value of 
> 11111110 will return NO if compared to YES).
> https://github.com/nytimes/objective-c-style-guide
> 
> What do you think of this?

Johannes,

I am replying to the discussion mailing list, as your mail most likely should 
have gone there, replying to a GitHub mail directly makes little sense.

I mostly agree with the style guide you are citing. And I really didn’t know 
that the NY Times was using Objective C, looks like they are even hiring :-) It 
is a shame that there are so few ObjC programmer offerings in Germany.
But back to the topic. This is what is common in all C based programming 
languages and I think Richard is following this principle very strictly in 
GNUstep base. The idea is to be open in what you accept, but strict in what you 
return. As far as I am aware he even makes sure to convert values he gets from 
calls to other methods to YES or NO before returning them. GNUstep qui is not 
that clean in this respect. The one line I just moved in the commit you are 
replying to is an example:

[v acceptsFirstMouse: theEvent] == YES

Here we don’t follow this principle and this is dangerous as a view we call 
this method on may not be as clean as the GNUstep code itself. Patches are 
welcome :-)

And why did I write that I „mostly“ agree? I would not follow this advice when 
the value is completely in our control.

Cheers,
Fred





reply via email to

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