Verified the problem here - that behavior doesn't seem right. Some simple
testing:

>> some-type: word!
== word!
>> switch/default some-type [word! [print "ok"]][print "not ok"]
ok

>> some-type: type? 'aword
== word!
>> switch/default some-type [word! [print "ok"]][print "not ok"]
not ok

 Seems like the literal word! doesn't match to the return of 'type?. To
support this, see below. Note that the return of 'type? is forced into the
"case" section of the switch, and it works:

>> case1: [x [print "ok"]]
== [x [print "ok"]]
>> change case1 type? 'aword
== [[print "ok"]]
>> print mold case1
[word! [print "ok"]]
>> switch/default type? 'aword case1 [print "not ok"]
ok

Looks like a bug to me.

As a work-around, if you don't want to violate your case-statements like
that, you could 'form or 'mold the results of 'type? and use strings for
the comparisons (yeah it's kinda strange, but 'mold returns a string on
datatypes).

- Michael Jelinek





Scott Dunlop <[EMAIL PROTECTED]>@rebol.com on 05/07/2001 09:07:30 AM

From: Scott Dunlop <[EMAIL PROTECTED]>@rebol.com on 05/07/2001 09:07 AM

Please respond to [EMAIL PROTECTED]

Sent by:  [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:
Subject:  [REBOL] Unable to use Switch and Datatypes..


Is this a bug or a feature?

The following code, which I would expect to generate 'A word is a word.',
outputs 'A word is not always a word.', indicating that word! is not
equivalent to word! for the purposes of switch.  This also appears to be
the case with the string! datatype.  The interesting thing is that [word!
==
word!] returns true.

  switch/default type? 'aWord [
      word! [ print "a word is a word."]
  ] [
      print "A word is not always a word."
  ]

Thanks in advance for any suggestions people have for working around this,
aside from a long chain of Either statements..

--Scott.



-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to