From: Jeff Wood Date: 2005-11-28T14:25:48+09:00 Subject: Re: String#to_rx ? ------=_Part_26438_23641922.1133155540983 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline No further response. There isn't a point. I've stated my opinion, you've stated yours. We aren't the only people in the world, and this is generatin= g far too much noise. Let it be. You've brought it up, and I'm sure other people will chip in with their $0.02USD j. On 11/27/05, Nikolai Weibull wrote: > > Jeff Wood wrote: > > > I do agree that I should have reviewed the document before posting a > > response. I have done that, and still hold to what I've stated. > > > > The Perl syntax he proposed is a hideous mess of line noise ( no > > surprises). > > So you think /(?:abc)/ is easier to read than /[abc]/? How about > /\w+\s*=3D\s*\w+/ versus / =3D /w (or /=3D/ > without 'w' modifier and assuming word =3D /\w+/)? > > > I don't believe that the suggested functionality can be added without > > slowing regular expression matching. > > What functionality are you talking about? The obvious one that slows > down matching is the one that executes arbitrary Perl (Ruby) statments, > but you're certainly not forced to use that functionality if you don't > want to, which brings us to... > > > But there IS one idea in the document I like and would require NO > > changes to regexp syntax. > > > > # define a normal regex with 1 group > > a =3D /(\d+)/ > > > > # add a rule for group 1s matching > > a.rules << Rexexp::Rule.new( :group, 1 ) { |val| val > 20 } > > > > # now play. > > b =3D "200 19 14 21 1" > > b.scan a > > #=3D>[ "200","21" ] > > > > ... at least that's how I'd do it ... Beyond that, I still feel > > trying to get anything more than "ideas" for features from Perl is NOT > > a good path for ruby. > > How is that easier to understand than > > b =3D "200 19 14 21 1" > b.scan /(\d+){ |val| val > 2 }/ > # =3D> ["200", "21"] > > ? With this syntax, it's pretty obvious what's going on, at least I > think so. "Match a sequence of one or more digits and call the given > block to see if we should actually accept it as a valid match." > > Furthermore, everything could be added _without_ changing the regex > syntax, but that's not the point. The point is to make the regex syntax > as expressive as possible, just like Ruby's syntax is as expressive as > possible (or at least tries to be). > > > Anyways, I do see value in what you brought to the table ... but maybe > > next time explain the feature for it's merits not "hey look what perl > > is doing!" ... > > I didn't even mention Perl in my original posting. I mentioned an > article about a new regular expression syntax, which happened to be for > Perl 6, but I didn't say "Hey, look what almighty Larry Wall has said we > must do." > > nikolai > > -- > Nikolai Weibull: now available free of charge at http://bitwi.se/! > Born in Chicago, IL USA; currently residing in Gothenburg, Sweden. > main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);} > > -- "Remember. Understand. Believe. Yield! -> http://ruby-lang.org" Jeff Wood ------=_Part_26438_23641922.1133155540983--