swarm-support
[Top][All Lists]
Advanced

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

Re: what's wrong with this use of the index to clean a list?


From: Paul E. Johnson
Subject: Re: what's wrong with this use of the index to clean a list?
Date: Wed, 27 Oct 1999 23:23:12 -0500

"Marcus G. Daniels" wrote:
> 
> >>>>> "PJ" == Paul Johnson <address@hidden> writes:
> 
> PJ> And I never do [offerList addLast:nil]. It must be the case, then,
> PJ> that I've got some other glitch in the model, so I add some
> PJ> nonexistand object to the list and it automatically slammed in a
> PJ> nil for me?
> 
> Perhaps there is an addLast: that adds the result of another method,
> and that that method can fail, returning nil?
> 
You were correct, as usual.

This experience has made me a little nervous about lists and processing
them with the usual kind of while statement, as in
   while( (member=[index next])!=nil).
and I understand why the 
  for(member=[index next];[index getLoc] == Member; member = [index
next])
fixes the problem.

Here is what I don't get:  what does the processing inside the loop do
when it gets passed a nil member value?  Suppose inside that for loop
there is a command
   [member doSomething];
?
Should the program be testing every "member" to see if it is not nil? 
Without doing that, I suppose I would expect a crash at run time saying
"nil does not respond to doSomething"?  But I have not seen such a
crash. 

-- 
Paul E. Johnson                         email: address@hidden
Dept. of Political Science              http://lark.cc.ukans.edu/~pauljohn
University of Kansas                    Office: (785) 864-9086
Lawrence, Kansas 66045                  FAX: (785) 864-5700

                  ==================================
   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]