[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Errors from includes & casts
From: |
Marcus G. Daniels |
Subject: |
Re: Errors from includes & casts |
Date: |
13 Sep 1999 17:27:45 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "DS" == Darren Schreiber <address@hidden> writes:
DS> Ok, now the reverse question... if I drop an object is that
DS> sufficient to also remove it from the lists it may be a member of?
DS> Or, do I need to remove it everywhere and then drop it?
Yep. But you can send addRef:withArgument: to objects in order to have
a function called when they are dropped. This is a robust way to
handle this kind of cleanup.
DS> But, I still am wondering why I get the
DS> SchellingWorld.m: In function
DS> `_i_SchellingWorld__findEmptyLocation_': SchellingWorld.m:64:
DS> warning: cannot find method. SchellingWorld.m:64: warning: return
DS> type for `getRandomIntMin:Max:' defaults to id
DS> SchellingWorld.m:64: warning: assignment makes integer from
DS> pointer without a cast
This means that the getRandomIntMin:Max: isn't declared. You'd need
to include the ModelSwarm file in order to get it, and make sure
that file could be included in this context. That might mean removing
some static typing of ivars.
DS> This points to question I have. It is my impression that lots of
DS> code I've looked at uses this "SchellingWorld * myWorld;"
DS> construction. Should I be declaring this pointer myWorld as type
DS> id first?
Using static typing like this has the advantage that you get some
cheap and easy minimal type checking done. For example, if you send a
message to myWorld and SchellingWorld doesn't respond to that message,
the compiler will warn you. If you type myWorld it as id, and that
method does exist (but isn't appropriate for myWorld), you won't get a warning.
The most flexible thing is to declare a protocol like this:
@protocol World
- (id <Location>)findEmptyLocation: (id <Agent>)agent;
@end
that lists all the methods that make sense for a world,
and an interface like this:
@interface SchellingWorld <World>
...
@end
Then type your world ivar like this:
id <World> myWorld
This way, you can have message checking and the flexibility to
drop in different worlds without touching any declarations.
==================================
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.
- Memory problem, Martin Gutting, 1999/09/10
- NT and Window Display, Jayshree Sarma, 1999/09/10
- Re: NT and Window Display, Marcus G. Daniels, 1999/09/10
- Re: NT and Window Display, Jayshree Sarma, 1999/09/10
- Errors from includes & casts, DARREN MATTHEW SCHREIBER, 1999/09/10
- Re: Errors from includes & casts, Marcus G. Daniels, 1999/09/10
- Syntax and use of ObjectLoader i/o files, William S. Shu, 1999/09/11
- Re: Syntax and use of ObjectLoader i/o files, Marcus G. Daniels, 1999/09/11
- Re: Errors from includes & casts, Darren Schreiber, 1999/09/13
- Re: Errors from includes & casts,
Marcus G. Daniels <=
- Re: Errors from includes & casts, Paul E. Johnson, 1999/09/14
Re: NT and Window Display, Marcus G. Daniels, 1999/09/13
Re: Memory problem, Marcus G. Daniels, 1999/09/11