On Tuesday 18 January 2005 17:44, Daniel Jung wrote:
Please do this:
eval me:tell(me ? I exist | I don't exist)
MOO objects don't seem to be true, and I cannot see why. Could anyone
enlighten me please. Both banana, 14, {1,2,3} and #1 should exist.
Object numbers are always false. If you want to see if an object exists, you
can use the built-in function valid(). So:
;player:tell(valid(player) ? I exist | I don't exist.)
If you're on a LambdaCore-style core, you can also use $recycler:valid() which
will tell you not only that the object exists, but that it hasn't been
recycled.
Type and example are returned true when it is a string (STR and
`banana'), an integer (INT and `14') and a list (LIST and `{1,2,3}').
But in OBJ, only the type is returned true; the example (be it valid or
not) is returned false. I find this inconsistent, but maybe this is so
by design?
Checking if the type returns true doesn't really tell you much. All the type
'constants' like LIST and STR evaluate to integers. For example, try:
;player:tell(STR)
Or just:
;STR
You'll probably get 2, but the idea is that the actual values shouldn't
matter. And if you test INT or NUM, you'll end up with false, since their
value is 0. So it's not a very useful thing to test the truth of.
Last example:
eval me:tell(ERR ? Errors exist | Errors don't exist)
eval me:tell(E_TYPE ? Mismatch exists | Mismatch doesn't exist)
You probably shouldn't think of it as a test for existence... Just an
arbitrary truth value which depends on the data type and is convenient
sometimes.
The short version:
STRs and LISTs are true when they're not empty.
INTs and FLOATs are true when they're not zero.
OBJs and ERRs are always false.
TTFN
Andy
#
This message is sent to you because you are subscribed to
the mailing list moo-cows@the-b.org.
To unsubscribe, E-mail to: [EMAIL PROTECTED]
To switch to the DIGEST mode, E-mail to [EMAIL PROTECTED]
To switch to the INDEX mode, E-mail to [EMAIL PROTECTED]
Send administrative queries to [EMAIL PROTECTED]