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

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

From: tomc:darkwing:uoregon at: 10-Dec-2002 21:01

Hi Joel On Mon, 9 Dec 2002, Joel Neely wrote:
> Hi, Tom, > > Responding with equal good will... ;-)
ditto, but more :)
> Tom Conlin wrote: > > > > no offense but, > > For me never having to see another regexp is a feature. > > Before this goes further I would like to see anything that > > can be done with regexps that can't be done with parse > > and being short & opaque doesn't count. > > > > Calling something "opaque" sounds (to my ear, at least) like more of > a value judgement than an objective description. However, it's quite > easy to look at two ways of expressing an idea to see if one is > significantly more "short" than the other.
for me opaque includes noticing I have a finger on the screen and the other hand leafing through a book trying to figure out something I wrote a few years back in perl4 ... (I do dislike fingerprints on my monitor)
> So... to respond to your inquiry, if we assume that two notations > (such as Perl and REBOL) are both Turing-complete, then anything that > "can be done" with one can be done with the other. However, that's > also true of assember... ;-) >
agreed. This does not address my statement about 'parse (or other 'grammar with backtracking' system) and regular expressions pattern matching, or the scale/complexity/problems each are sufficient to cover. I work in "bioinformatics" and perl is the fields darling. The author of the claimed perl saved the human genome project, he may be right, in any case there is so much existing code I will not be getting away from it anytime soon. And regexps are by no means limited to perl, oddly I don't mind them as much in other Unix commands because there they seem more appropriate (my being subjective does not bother me)
> Some time back we had a long discussion about removing redundant > whitespace from a string. This is an area where the "search-and- > replace" usage of regular expressions provides some real notational > economy, IMHO. > > $bigstring =~ s/\s+/ /g; > > Please, everyone, before complaining about the punctuation, get over > it and look at the real point; that expression says (compactly) the > equivalent of this: > > Within the variable named "bigstring" replace all runs of > whitespace (*) with a single blank. > > (*) technically it says "one or more consecutive whitespace > characters", which I feel justified in verbalizing as > "runs of whitespace". >
Ahh, first let me say that I (as I'm sure many on this list) find your posts to be an education, you are thoughtful and follow thru with a mathematical precision I envy, so here where you are putting effort into being clear and consice about a construct in a language which I will guess you have been programming in at least twice as long as you have used rebol... that flaw could creep thru is very telling. Q: does the regrxp do what it is intended to? A: only if you also wanted to replace every_single space with a single_space as well. an expression that may come closer to your intent is $bigstring =~ s/ \s+/ /g; replace all runs of more than one white space with a single whitespace. You may be able to wiggle around and say there is nothing to explicitly prohibit runs of one but we know you do not do choose to unnecessary computation. I am not the careful bench-marker that you are but running the two regexps over a 21M logfile showed the latter ran in half the time of the original and that is not something the Joel we know and love would do. thanks for demonstrating that which I was merely reacting unconstructively to.