[MOO-Cows] Re: Cogito ergo sum

2005-01-18 Thread Andrew Wendt
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]



[MOO-Cows] Re: Cogito ergo sum

2005-01-18 Thread Sean Davis
On Tue, Jan 18, 2005 at 07:18:04PM -0800, H. Peter Anvin wrote:
 Sean Davis wrote:
 On Wed, Jan 19, 2005 at 02:44:49AM +0100, Daniel Jung wrote:
 
 Hi all
 
 [LambdaMOO 1.8.0r5]
 
 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.
 
 Then do this
 
   eval me:tell(OBJ ? Objects exist | Objects don't exist)
 
 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?
 
 Last example:
 
   eval me:tell(ERR ? Errors exist | Errors don't exist)
   eval me:tell(E_TYPE ? Mismatch exists | Mismatch doesn't exist)
 
 
 
 All I can say is... weird. My results seem to confirm yours, running
 1.8.1+foo2.7.4:
 I don't exist
 Objects exist
 Errors exist
 Mismatch doesn't exist
 
 
 RTFM.  Type names are actually integers.

Yes, they are. I was merely running the suggested evals. No need to RTFM
at me. I'm quite aware that type names are integers. I merely found the
results of those tests... curious... for lack of a better word.

-Sean

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