• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C question for you old guys ;-)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C question for you old guys ;-)


  • Subject: Re: C question for you old guys ;-)
  • From: Chris Ridd <email@hidden>
  • Date: Mon, 09 Jun 2003 15:57:49 +0100

On 9/6/03 2:58 pm, Steve Bird <email@hidden> wrote:

> On Monday, June 9, 2003, at 08:43 AM, Dan Sugalski wrote:
>
>> At 11:30 AM +0200 6/9/03, Marcel Weiher wrote:
>>> I guess I should have been a little more explicit. I wouldn't do
>>> either of the above, but rather:
>>>
>>> if ( spriteInfo == NULL ) {
>>> return nil;
>>> }
>>
>> Having been bitten by C's block issues before, I do that as well, but
>> I try and take it one step further and do:
>>
>> if ( NULL == spriteInfo ) {
>> return nil;
>> }
>>
>> putting the constant on the left-hand side of the equality test. It
>> catches the times when I miss a = in the test--"NULL = foo" throws a
>> compile-time error, "foo = NULL" leads to a bughunt session.
>
>
> --- I wrestled with this and came out against it.
> Mainly because it goes against "natural" thinking: I always think
> if (changeReceived == 31 cents)

Looking at that pseudo code reminds me of the C source that apparently had

#define k *1000

just to allow a hardware engineer to write '100 k' in an expression (think
resistors). The bug was allegedly uncovered when someone tried defining a
variable called 'k' and wondering why he got compiler errors :-)

Nearly as bad as '#define private public' prior to including a C++ header
:-))

Cheers,

Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: C question for you old guys ;-) (From: Steve Bird <email@hidden>)

  • Prev by Date: Re: C question for you old guys ;-)
  • Next by Date: Re: Serious AddressBook framework problems
  • Previous by thread: Re: C question for you old guys ;-)
  • Next by thread: Re: C question for you old guys ;-)
  • Index(es):
    • Date
    • Thread