The Difference Between NIL and NULL...

Discussion in 'Mac Programming' started by Darkroom, Jul 15, 2008.

  1. Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
  2. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    Style.

    They will both be compiled to 0.

    From what I can tell the stylistic difference is that NULL is used to indicate a null pointer to a primitive type, and nil is used to indicate a null pointer to an Object.

    -Lee
     
  3. macrumors 6502a

    Joined:
    May 15, 2007
    #3
    NIL is no value/zero. We're winning 5-nil
    NULL is the absence of data (when writing software)
     
  4. macrumors 68040

    iSee

    Joined:
    Oct 25, 2004
    #4
    Assuming we're talking about Objetive-C:
    nil (all lower-case) is a null pointer to an Objective-C object.
    Nil (capitalized) is a null pointer to an Objective-C class.
    NULL (all caps) is a null pointer to anything else.

    So, conceptually, they mean the same thing but for different categories of things. They all have the same representation, too; they all happen to have the numeric value of 0.

    I don't know whether or not NIL (all upper-case) has special meaning in Objective-C.
     
  5. macrumors regular

    Joined:
    Jun 27, 2008
    Location:
    Washington D.C.
    #5
    Darkroom, I believe on your avatar, the letter immediately following NS should be capitalized.
     
  6. thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #6
    but then it would be an ex-object... and NSSexObject doesn't play with the term/concept as much... anyway...:rolleyes:

    so to get this straight...??

    Code:
    [NSApp beginSheet:sheet
       modalForWindow:mainWindow
          modalDelegate:nil                 [COLOR="SeaGreen"]//pointing to an [I]object[/I] (modelDelegate?) and making it zero?[/COLOR]
          didEndSelector:NULL             [COLOR="SeaGreen"]//pointing to a [I]non object/class[/I] and making it zero?[/COLOR]
               contextInfo:NULL];           [COLOR="SeaGreen"]//pointing to a [I]non object/class[/I] and making it zero?[/COLOR]
    
     
  7. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
  8. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
  9. macrumors newbie

    Joined:
    Aug 30, 2008
    #9
  10. macrumors 68000

    Littleodie914

    Joined:
    Jun 9, 2004
    Location:
    Rochester, NY
    #10
    Yea, the different types can get confusing at times. In all my experience, I've only used the "nil" and "NULL" keywords, referring to an objective-c object pointer, and a primitive type pointer, respectively. I've never needed anything else, but maybe I just haven't gotten deep enough. :D
     
  11. macrumors member

    Joined:
    Sep 29, 2007
    #11
    NIL is a reserved word in Pascal, I don't know what it would be doing in C (although I've never used objective C). Like NULL, it's value is usually zero.
     

Share This Page