Jean Michel <jmichel / schur.institut.math.jussieu.fr> wrote: >Josh Stern <jstern / foshay.citilink.com> wrote: >>Jean Michel <jmichel / schur.institut.math.jussieu.fr> wrote: >>> Now, I want to re-use my code to parse an ID3V3 tag sitting in a string >>>in memory. In C++, I can just make the string into an istringstream and >>>share the same code. I don't see how I can share the code between both >>>situations in ruby (of course there would be a way: put the code in >>>class String and read the file in memory; but this is not desirable with >>>multi-megabyte files!). It seems that I need a class in which both >>>strings and files can belong, but I cannot do it since neither String >>>nor IO is a module. What did I miss here? >> >>I think you haven't adequately explained to the Ruby developers >>what it is that you really want. >> >>What is missing from the discussion is a description >>of the specific API that is to be shared and what amount of code >>resuse one has in mind. >.... >I think that these questions and the rest of your answer are beside the >point. I'm sorry that you found it irrelevant, but I noted that the code sharing in C++ iostream is based on sharing through an underying structure which is basically a strstream, and that is exactly what you have implemented in Ruby - for a few methods at least. In your solutions, the methods read and seek are shared in name only, not actual code - as is the case with template polymorphism in C++. -= Josh