From: Caleb Clausen Date: 2005-08-03T02:18:33+09:00 Subject: Re: Defining regexp's and variables set by them On 8/1/05, Garance A Drosehn wrote: > A few of the regexp's are based on global options, which is > to say a regexp would be constant for any one run of the > program, but it is built from the value of other variables. I > don't do that very often, but sometimes I do. This is what the /o regexp option is for; it forces the regexp to be compiled only once, even if it has interpolations. > Does > ruby keep the compiled-code for a method after the method > is finished? Uhhh, it's nowhere near that fancy. Ruby is a fairly traditional interpreter, without even bytecode compilation. That's why it's so slow. > But the main reason I like to split things up is that the > regexp's involved in my real-world example are rather > complicated. I'd like to have one section of code which > defines the regexp's, and comments why they are the > way they are. But you were just saying you don't like the regexp distant from it's use... > What about it? My program isn't doing to_s on any regexp's > which it defines, so I don't understand the significance of your > question... Maybe not, but if it's to be a general solution, you need to handle all this stuff. If you're just going to use it in your own program, then that's fine but I thought you were talking about something more general-purpose. You maybe be calling Regexp#to_s without knowing it if you do something like this: rex1=/bar/ rex2=/foo#{rex1}baz/ The interpolation calls to_s.