From: daz Date: 2004-03-07T23:34:41+09:00 Subject: Re: freeze, frozen? in extensions Tim Hunter wrote: > I'm poking around in the 1.8.1 ext/ sources and I notice that there are > very, very few uses of rb_check_frozen. I expected to see the C extensions > calling rb_check_frozen before modifying them. What am I overlooking? Is > it just not necessary? Calling a C extension which uses rb_str_modify() and /not/ rb_check_frozen_p() on a string that's frozen before the call gives: D:/ruby/DfB/rb6062.TMP:3:in `call': can't modify frozen string (TypeError) No reason why that should be expected, though. You could have two exts that do the same job -- one causing a TypeError, but not the other. As a Ruby String points to a C string, it would easily be possible for an ext just to overwrite part of the C string even if it had been frozen but (you made me think) Ruby objects *always* are/should be modified via the API rather than directly which allows Ruby to check things such as /frozen/ status. That may be a rule which just *feels* right to my narrow experience. If I learned it, it was only a few moments ago. I'd retract it if someone offered the glaring exception(s) :) daz