Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Problems with block of datatype!s

 [1/4] from: tim:johnsons-web at: 12-Sep-2001 9:40


I would like to be able to test a word for a match in a block whose members are datatypes. The example code doesn't do what I want it to do:
>> types: [string! number!]
== [string! number!]
>> find types string!
== none ; was hoping for [string! number!]
>> types/1 = string!
== false ; was hoping for 'true Just curious: what else do I need to do here? TIA tj

 [2/4] from: ryanc:iesco-dms at: 12-Sep-2001 10:31


Hey Tim, datatypes seem strange this way. I found the same thing with 'select some time ago. I eventually somehow figured out that the trick is to pass the datatype as a word. I just now noticed that this can be tricky if you need to convert your datatype, example:
>> to word! string!
** Script Error: Expected one of: word! - not: datatype! ** Where: do-boot ** Near: to word! string!
>>
Ho, ho, ho. Merry feedback. After goofing around for awhile I came up with this quick fix for you...
>> datatype-to-word: func [dt [datatype!]] [first to-block
join dt "!"]
>> type? probe datatype-to-word string!
string! == word!
>>
I will send a copy of this to feedback. --Ryan Tim Johnson wrote:
> I would like to be able to test a word for a > match in a block whose members are datatypes.
<<quoted lines omitted: 12>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400

 [3/4] from: holger:rebol at: 12-Sep-2001 10:55


On Wed, Sep 12, 2001 at 09:40:34AM -0800, Tim Johnson wrote:
> I would like to be able to test a word for a > match in a block whose members are datatypes.
<<quoted lines omitted: 6>>
> == false ; was hoping for 'true > Just curious: what else do I need to do here?
Change types: [string! number!] to types: reduce [string! number!] The reason is: In your block, "string!" is an unevaluated word (type word!), but in your call to 'find "string!" gets evaluated and becomes the datatype! "string!". Words are different from datatypes, so no match is found. Reducing the block evaluates the words in it and converts them to datatypes, allowing 'find to do what it should. This is not a bug btw. -- Holger Kruse [holger--rebol--com]

 [4/4] from: tim::johnsons-web::com at: 12-Sep-2001 11:10


On Wed, Sep 12, 2001 at 10:55:45AM -0700, Holger Kruse wrote:
> On Wed, Sep 12, 2001 at 09:40:34AM -0800, Tim Johnson wrote: > > I would like to be able to test a word for a
<<quoted lines omitted: 18>>
> Reducing the block evaluates the words in it and converts > them to datatypes, allowing 'find to do what it should.
Thanks Holger
> This is not a bug btw.
I had no suspicion that it would be, I suspected that the answer would be in 'bind or 'reduce which are rebol terms that my feeble brain has yet to fully absorb. Also: Holger, if you are still on line, I need to post something that I wish to CC to you and Carl. A small piece of good news for Rebol ..... which might need your input. regards tim

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted