Re: NOWHERE, NOBODY, NOTHING tests...

From: Peter Ajamian (peter@pajamian.dhs.org)
Date: 03/05/01


George Greer wrote:
>
> Just because the official CircleMUD happens to use an array doesn't mean
> someone else hasn't rewritten it to use a linked list with pointers or an
> SQL database.

And, as I pointed out earlier, it would be simple for them to change the
testing macros to account for that.

> You should never have a -2, -3, -4, etc.

Exactly my point.  If you should never have them then why not report a
SYSERR in the case where we get them instead of crashing?

> I'd like to know where these negative numbers are coming from, personally.

There will always be someone who tries to use -2 for something, maybe to
indicate a special location where a player is that is, in reality, not a
real room, but where they want to differentiate that from NOWHERE.
While there's nothing wrong with that, the way that CircleMUD is
currently, they would have to grep through the entire source and fix all
the spots that test for '== NOWHERE' and fix them to work properly for
thier source.  If there is a macro defined for the test they only have
to change the macro and a few spots, and even if they don't change the
macro thier code will still work without crashing the MUD (it will have
a SYSERR in the log to remind them to fix the test).

> >Also note that setting up a macro for
> >IS_NOWHERE()/IS_NOTHING()/IS_NOBODY() will accomplish the same thing
> >with the same ease of portability and allow testing for conditions that
> >a simple == NOWHERE/NOTHING/NOBODY can't possibly allow for.
>
> I'd imagine the other interesting value of NOWHERE is NULL.  I think the
> simple test does quite well with that.

The simple test will do "quite well" testing a variable against _any_
single value.  It is when you get values that can do damage and are not
anticipated that you get into trouble.

> It's very likely someone forgets about dummy_mob (see the mailing list
> asking about the warning), it's very unlikely someone gets a room number
> return code of -2 without trying.  That's what NOWHERE is, a marker.

Unlikely, yes, but still possible and under ceartain circumstances
feasable.

Regards, Peter

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/04/01 PST