swarm-support
[Top][All Lists]
Advanced

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

Re: Problem with NSelect


From: Alex Lancaster
Subject: Re: Problem with NSelect
Date: 27 Sep 1999 14:30:56 -0600
User-agent: Gnus/5.070095 (Pterodactyl Gnus v0.95) Emacs/20.4

[...]

DS> -step {
DS>   id bestLocation;
DS>   id newLocation;
DS>   id <List> emptySpacesList;
DS>   id <List> optionsList; // Will hold a list of possible places to live.
DS>   int i, s;
DS>   int listLength;
DS>   float bestUtility;
DS>   id <NSelect> selector;
DS>   
DS>   selector=[NSelect create: [self getZone]];
DS>   optionsList=[List create: [self getZone]];
DS> 
DS>   [selector select: 5 from: emptySpacesList into: optionsList];

DS> I get the following compiler error: 

DS> Person.m: In function `_i_Person__step':
DS> Person.m:82: warning: method `select:from:into:' not implemented by
DS> protocol.

`select:from:into:' is a *factory* method (identified by the `+' sign
in front of the method name, rather than the usual `-', these are
often known in C++ and Java-land as class-methods:
`System.out.println()' in Java, is an example of a class method)

This means that you don't need to create in *instance* of NSelect and
then call a *instance method*, but you just use call the *class
method* directly on the class name.  Try:

  [NSelect select: 5 from: emptySpacesList into: optionsList];

leaving the protocol declarations in place.  Btw, Object{Loader,Saver}
and QSort in simtools work in the same way.

 --- Alex

-- 
  Alex Lancaster           |  e-mail: address@hidden
  Swarm Program            |     web: http://www.santafe.edu/~alex
  Santa Fe Institute       |     tel: +1-(505) 984-8800 (ext 242)
-------------------------------------------------------------------

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