Your code looks good to me, but I'm not familiar with Java so I couldn't tell
you how your accent is. The most un-REBOL-ian thing I can detect is the use
of comma to separate your list of types.
It looks like you want to print out a list of all datatypes to which a value
belongs. How about this?
unset!: (type?) ; not defined in REBOL/Core
action!: type? :action ; ditto
show-all-types: func [
{print out all relevant datatypes for a value}
value [any-type!]
/local typelist valuelist to-do
][
foreach [type list] reduce [
unset! "unset!"
datatype! "datatype!"
action! "any-function! action!"
op! "any-function! op!"
][
if type = type? get/any 'value [print ["any-type!" list] exit]
]
typelist: copy []
valuelist: head insert/only copy [] :value
foreach word first system/words [
if datatype? get/any word: in system/words word [
if find valuelist get in system/words word [
append typelist mold word
]
]
]
print typelist
]
>> show-all-types
any-type! unset!
>> show-all-types number!
any-type! datatype!
>> show-all-types :+
any-type! any-function! op!
>> show-all-types :op?
any-type! any-function! action!
>> show-all-types [EMAIL PROTECTED]
any-type! series! any-string! email!
>> show-all-types 29.12
any-type! number! decimal!
>> show-all-types try [length?]
error! any-type!
>> show-all-types first [set/path:]
any-type! series! any-block! set-path!
Set-path values are also any-block values! I would never have guessed that!
It's a little-known fact that you can use FIND to find values in a block of a
particular datatype, but unfortunately you'll also find the datatype value
itself, so the behavior is a little unpredictable. (There are a few other
intractable cases I had to provide special processing for with the logic
you've suggested.)
>> find reduce [30 number!] number!
== [30 number!]
>> find reduce [number! 30] number!
== [number! 30]
Oddly enough, there are no words assigned for the ACTION! and UNSET!
datatypes. I've been lobbying to have this oversight fixed, with no success
so far. It's too bad, especially since UNSET! can be quite useful.
See you,
Eric