From: Joel VanderWerf Date: 2006-02-08T08:59:28+09:00 Subject: Re: marshalling constants Eric Hodel wrote: > On Feb 7, 2006, at 11:38 AM, Brian Buckley wrote: > >> Hello, >> >> When one marshals a constant and later unmarshals it, a brand new object >> appears to be created during unmarshalling. This seems wasteful, >> especially >> in cases when constants are large (contain many attributes). Is it >> possible >> to customize marshal for a class (or for singleton objects of the >> class) so >> that unmarshalling a constant simply returns the already existing >> constant >> rather than creating a new one? I've noticed Fixnum's exhibit this >> behavior. > > How do you know that a Marshal string is identical to a constant without > loading it? In some cases, the identity is the name of the constant, not the value. And that's something that is possible to marshal consistently. > Note that Ruby doesn't really have constants. Instead it has frozen > objects which aren't quite the same thing. I'm assuming the OP meant constant in the sense of binding, which ruby does have. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407