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

[REBOL] Re: using type? with switch

From: deadzaphod:flyingparty at: 1-Oct-2001 17:18

Great explanation! (although I've got one tiny addition below ;-] )
> This means that TYPE? VB evaluates to BLOCK! which matches > the first "action block" in the target/action pairs (item 2) > which returns the next element (item 3) as the result to be > DOne by the SWITCH. > > You can use a couple of alternative work-arounds to this > very non-intuitive (and undocumented?) state of affairs: > > 1) make the selection target a string, as you mentioned > (it would be nice if TO-WORD could take a datatype as > an argument which would then match in the non-REDUCEd block, > instead of blowing up in one's face!) > > 2) create your own SWITCH variation that avoids the problem > by forcing target/action parity:
3) use reduce to solve the WORD! / DATATYPE! problem and always have BLOCK! as the first option in the switch to avoid the "feature" of matching the first action block. Cal Dixon