From: Niklas Frykholm Date: 2005-03-16T03:06:27+09:00 Subject: Re: Problem with aliasing String#index >> To fully duplicate the functionality of the built-in String#index I >> need to transfer $~ from the local scope to the enclosing scope. Is >> there any way of doing this? > > > There's a solution in the ruby-talk:79283 thread that was posted by > matz, but it's not thread safe. It would be wonderful if we could have > a proper way of doing this... Ah... interesting... but that technique doesn't really work with String#index, since String#index doesn't take a block. I think I just have to resign from the idea of making a completely transparent String wrapper. But it would be nice if this was resolved. In principle, I think it should be possible to do the same things from Ruby as from C. I.e. if C can set a variable $~ in the caller's scope, it should be possible to do that from Ruby as well. // Niklas