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

[REBOL] Re: Parse versus Regular Expressions

From: joel:neely:fedex at: 4-Apr-2003 17:13

Hi, Gregg, Gregg Irwin wrote:
> << 2) It totally breaks normal usage that "or" is symmetrical, even > though we read the | as "or". >> > > It's like the ANY function, so I don't know that I'd say it "totally > breaks" normal usage. Isn't OR often optimized to work this way; i.e. > shortcut evaluation? >
In REBOL (at least) OR does *not* shortcircuit, but ANY does:
>> any [do [print "1" true] do [print "2" true]]
1 == true versus
>> (do [print "1" true]) or (do [print "2" true])
1 2 == true However, that's beside the point if we're talking about symmetry; in REBOL *both* OR and ANY are symmetric (over pure logic values), in the sense that the result is independent of the order of the arguments: foreach a reduce [true false] [ foreach b reduce [true false] [ print [a b equal? any [a b] any [b a] equal? (a or b) (b or a)] ] ] yields true true true true true false true true false true true true false false true true So it's not like ANY in that respect.
> I think the most important thing, barring actual "bugs" in PARSE's > design is documenting how these things work so grammars can be designed > correctly (e.g. longest match first; greedy grammars? :). >
I totally agree with that statement. -jn- -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446 Counting lines of code is to software development as counting bricks is to urban development.