Patrick R. Michaud via RT wrote: > On Mon Dec 22 16:41:53 2008, zev wrote: >> Oops. The last patch wasn't quite right. This one passes the tests >> (which I found). I also added spectests that are marked TODO (but which >> pass with this patch applied). > > I would prefer to see this done by using a smart match on the :x() > argument instead of explicitly checking it for a Range and grabbing > min/max from there. Using a smart match would allow things like > :x(1|5|7) and :x({ .is_prime }) to work properly. > > Pm > >
I just tried working this out (I'm still learning PIR). With the simple implementation (which is analogous to the way it currently works), subst does substitutions until it's internal counter ACCEPTS the argument to :x(). However, this means that it terminates as soon as it has substituted enough to be within the range. The semantics we want, I believe, is for subst to do as many substitutions as it can while still fitting the :x() constraint. This leads to some sort of backtracking solution, which isn't going to be very efficient. Can we punt to the regex engine for taking care of the :x() argument? Zev