From: Nikolai Weibull Date: 2003-10-10T03:00:37+09:00 Subject: Re: Extension Language for a Text Editor * Robert Klemme [Oct, 09 2003 18:42]: > Since others have commented on various aspects of your posting I'll only > throw my 2c at this: > > Also, is there any way of redefining the // operator for constructing > > regular expression objects? I'm planning on implementing a new regex > > syntax for the editor (to make searches/substitutions easier to > > describe). > Why do you want to change it? I find it quite flexible and expressive > (especially when using flag "x"). And especially if you want to attract > rubyists to use TREC (The Ruby Editor to Come), then you should ensure > that their knowledge of ruby regexps is not obsoleted, since rx's will > likely play an important role in user defined extensions! Hehe. Yeah, that is true. So we'd need two separate constructs. > > You can always define methods in Kernel like this: > > irb(main):002:0* module Kernel > irb(main):003:1> def rx(str) > irb(main):004:2> puts "building rx from '#{str}'" > irb(main):005:2> end > irb(main):006:1> end > => nil > irb(main):007:0> > irb(main):008:0* rx %q{(foo)+ \s+ (\w+)} > building rx from '(foo)+ \s+ (\w+)' > => nil > irb(main):009:0> rx '(foo)+ \s+ (\w+)' > building rx from '(foo)+ \s+ (\w+)' > => nil > irb(main):010:0> > > Which isn't too bad IMHO. > No, it isn't actually. Thank you for pointing this out. This could actually be the answer to my question. I'll have to think about this. I had totally forgot that we had very restrictive single-quoting contexts (and even the %q{}). Thanks, nikolai P.S. I realize now that that last part may seem a bit sarcastic, but it isn't, I promise. D.S. -- ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka ::: ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden ::: ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 ::: main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}