From: Massimiliano Mirra Date: 2002-03-20T23:51:24+09:00 Subject: Re: [ANN] Xml Serialization for Ruby On Tue, Mar 19, 2002 at 10:53:44PM +0900, Morris, Chris wrote: > Again, another good point. Even with my typeless approach, array and hash > will have to have type elements ... well, no they wouldn't -- but we need > some way of delineating each element or key/value pair. Right now it's: > > > thing > > > > > thing > other thing > > > > I'd like to be able to squeeze those down somehow. Hmmm... how do you know what class are the contained elements going to be? Do you parse the element content? > > I agree, that feels more OOP to me too. My application had some > > requirements that prevented that: > > > > - I did not know in advance what classes had to be marshallable; > > - even if I did, I could not create a marshaller object for each of > > them because there were going to be a lot and performance would have > > decreased; > > - I could not use a global object either, as the stuff needed to be > > thread safe, and I could not use a mutex for the same > > performance reasons. > > Hmmm ... that's interesting. I can see with your first issue where my > approach just wouldn't work -- well, could you include the module into > Object? > > class Object > include XmlSerialization > end > > The mods to the standard types would still work, and then everything (?) > gets to_xml from_xml? > > As for the other two options, does the included module in Object handle > performance and threading issues? Because you wouldn't have all these > additional marshaling objects -- they're built into each object you already > have. Marshalling requires an instance of an XML parser. To be thread safe, either as many instances are serializable objects would be needed (resource unfriendly), or a global instance with mutex access (performance unfriendly), or a limited number of instances scheduled by some mechanism (programmer unfriendly ;-) ). Well, but I'm taking for granted that you are marshalling XML back into objects via an XML parser, too, and I might be wrong as I've not looked into the internals of your code... Massimiliano