[#8815] Segfault in libc strlen, via rb_str_new2 — "Sean E. Russell" <ser@...>

Howdy,

12 messages 2006/09/09
[#8817] Re: Segfault in libc strlen, via rb_str_new2 — Eric Hodel <drbrain@...7.net> 2006/09/09

On Sep 8, 2006, at 10:10 PM, Sean E. Russell wrote:

Re: Literal inconsistency

From: Calamitas <calamitates@...>
Date: 2006-09-04 15:00:10 UTC
List: ruby-core #8790
On 9/4/06, Christian Neukirchen <chneukirchen@gmail.com> wrote:
> I don't see the inconsistency.  Regexps are immutable anyway, so this
> optimization is useful.  You probably wanted Regexp.new("hello")?

Well, immutable is relative:

  2.times do
    a = /hello/
    puts a.instance_eval { @a }
    a.instance_eval { @a = 5 }
  end

This prints nil, then 5. So only part of a regexp is really immutable.

Also, note that Regexp.new("hello") compiles the regexp on each
execution. Regexp.new(/hello/) probably doesn't, so that would work.

Anyway, I agree there is a work-around, and inconsistent is relative
too. It just bit me unexpectedly, and it seemed inconsistent to me.

Peter

In This Thread