[SVN] r3154 (Objective-C)

Chris Thomas chris at cjack.com
Mon May 1 14:13:11 UTC 2006


There's no impact on the generated binary, but there's a negative  
impact on source code maintenance.

In C, it's easy to inadvertently type "a = b" (assignment) where you  
intended "a == b" (equality). I've occasionally found such bugs in  
large code bases. The compiler can find this error for you by issuing  
warnings for assignments in if-statements. In GCC, this is controlled  
by -Wparenthesis.

If nothing in the standard snippets should cause a warning, the  
assignment should be outside of the if statement.

Chris

On May 1, 2006, at 9:26 AM, Rob Rix wrote:

> How so? I mean, the assignment is happening anyway. What kind of  
> difference does it make to add another line for it?
>
> Rob
>
> On 30-Apr-06, at 10:01 PM, Chris Thomas wrote:
>
>> I think assigning before the if is a better idea for style and  
>> didactic reasons, but the change was to sync with Xcode, IIRC.  
>> Apple has modified their templates to place the assignment outside  
>> of the if statement.
>>
>> Chris
>>
>> On Apr 29, 2006, at 1:15 PM, Allan Odgaard wrote:
>>
>>> • not sure if there was a reason to move the assignment out of  
>>> the if (to make the test explicit), but now it’s back!
>>>
>>> Changed:
>>> U   trunk/Bundles/Objective-C.tmbundle/Snippets/020 Class  
>>> (objc).plist




More information about the textmate-dev mailing list