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

[REBOL] Re: REBOL embedded $variables regexp/no

From: joel:neely:fedex at: 10-Dec-2002 13:35

Hi, Gabriele, Gabriele Santilli wrote:
> JN> Please, everyone, before complaining about the punctuation, > JN> get over it and look at the real point; that expression says > JN> (compactly) the equivalent of this: > [...] > > Joel, you are right, but also consider that if I look at it, I > don't understand what it is doing. >
I completely agree, but there are multiple situations that give me trouble when trying to read and digest some notation: 1) When I'm not familiar with it; 2) When it is so condensed as to be cryptic and/or error prone; 3) When it is so verbose that it takes much writing to say simple things. The first is simply a matter of education and experience. The second is certainly an accusation leveled at some notations. The third is harder to detect, but certainly affects productivity and scalability.
> Of course, that applies to every language, but if you look at: > > replace/all s "tetx" "text" > > you can guess what it is doing even if you don't know REBOL at > all. >
But the second argument is restricted to specific literals; there isn't an option to express a more general case (such as "run of whitespace of arbitrary length").
> >> digits: charset "1234567890" > >> chars: complement digits > >> pattern-replace "Replace 5248 with a #" [any chars] [some digits] "#" > == "Replace # with a #" >
That's a nice hack (seriously!), but isn't it odd that REBOL allows one to build anonymous functions ... map some-block func [x] [x * x - 1] ... but we have to use nested definitions with explicit names for all but the most trivial cases of PARSE rules???
> Matching a pattern and defining a grammar are two different > things, of course. >
I agree totally!
> However, I am convinced that grammars are much more general and > useful than patterns. >
I'd prefer to say that each has its own strengths and weaknesses. A spreadsheet is a more general tool than a four-function calculator, but there are situations where a calculator is more than adequate (and requires much less overhead than firing up a full-featured spreadsheet). (OF course, this is a poor analogy!) I've encountered *many* situations where it would be very convenient to write a pattern for some specific thing I'm looking for, rather than having to write a comprehensive grammar that includes all the other stuff I don't care about. I simply think each has it's place. -jn- -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446