On 2003.12.28 16:27, Yukihiro Matsumoto wrote:
> Hi,
> 
> In message "Re: [BUG] Can't call to_s on a frozen Date"
>     on 03/12/29, Gavin Sinclair <gsinclair / soyabean.com.au> writes:
> 
> |When I found the problem, I unfroze my dates (and had to unfreeze a
> |few other things as well, I think) and there was no more problem.   
> So
> |I wouldn't say that freezing dates is all that important.  However,
> if
> |someone freezes an arbitrary object, and somewhere else prints an
> |arbitrary object, they're going to be pretty annoyed when their
> |program stops working.  I guess it could be considered pathological.
> 
> I understand.  The point is how we can fix, or not.

It may add a slight overhead, but what about changing the once method?

In date.rb

714:    (@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0]

to

if defined?(@__#{id.to_i}__) then
	@__#{id.to_i}__[0]
else
	frozen? && __#{id.to_i}__(*args, &block) ||
            (@__#{id.to_i}__ =  [__#{id.to_i}__(*args, &block)])[0]
end

That should allow already cached values to be used in preference, but  
fallback to using calculated values otherwise.