From: Yukihiro Matsumoto Date: 2005-08-04T01:13:55+09:00 Subject: Re: array or with non-array Hi, In message "Re: array or with non-array" on Thu, 4 Aug 2005 00:58:51 +0900, Caleb Clausen writes: |Yukihiro Matsumoto wrote: |> Again, it's a matter of cost. For example, full duck typing |> Regexp#match likely requires re-implementation of a regular expression |> matching engine in Ruby. | |Not really, no. You can read into a buffer and match against the |buffer. This works pretty well for every pattern without anchors. |Supporting anchors too requires a smidge of rewriting the Regexp at |runtime. My current implementation interprets ^ and \A (or $ and \Z |when matching backward) as matching at the current file position, |rather than the beginning of file. | |It's a minor pain, but I have most of the necessary code already. |There's a compromise or two that have to be made: an upper limit on |the length of a single match, ^ won't work right in some rarer cases |until regexp lookback in ruby 1.9. I don't like this, but these |restrictions seem minor enough, considering the massive increase in |functionality otherwise. It's good to hear it's not impossible. Although I'm not agree very much about "massive" increase of functionality. matz.