swarm-support
[Top][All Lists]
Advanced

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

Re: Request for 2 Obj-C explanations. NULL/nil and "empty int" return


From: Marcus G. Daniels
Subject: Re: Request for 2 Obj-C explanations. NULL/nil and "empty int" return
Date: 28 Jun 1999 11:49:17 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.3.10

>>>>> "PJ" == Paul Johnson <address@hidden> writes:

PJ> 1.  NULL versus nil. Sometimes when an object does not exist,
PJ> example code says "return nil" and other times it says "return
PJ> NULL".  

nil should be used when you have a function or method that returns
an object, but may also want to return the absence of an object.  

Nil is the same, except for classes.

NULL is for the absence of a pointer.  It happens NULL, nil, and Nil
are all zero, but it is arguably bad style to count on that.  It's
also arguably also the case that if someone came along and
redefined `id' or `Class' to be `int' (an independent reference count,
say), huge amounts of code would break.

PJ> But to be perfectly accurate, they ought to use nil. 

Yes.

PJ> 2. If a function returns an int, and the integer is not defined
PJ> within the function, what is returned then?  Not NULL, I know
PJ> that.  How do you test for "undefined integer"?

If a correct return value can only be positive, it is common to
return -1.  Most Unix system calls are like this.


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

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