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

[REBOL] Re: More dialects than you think, validating function input.

From: g:santilli:tiscalinet:it at: 12-Sep-2002 15:26

Hi Brett, On Thursday, September 12, 2002, 2:05:39 PM, you wrote: BH> if not parse block [ BH> any [set value number! (kount: kount + 1)] | BH> set value any! to end BH> ] [throw make error! "F2 can only process numbers."] The second part of the rule will never be reached. ANY does not fail if it matches 0 elements. In your trivial example, your code could look like: if not parse block [any number!] [ ... provided you are accepting empty blocks as input too. Of course, I imagine your example was actually cut down form something bigger, that needed the SET VALUE ... and the count (which you could maybe do faster by just using LENGTH?...). Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r