On 12/28/10 12:07 PM, Sean Kelly wrote:
Michel Fortin Wrote:So because of all this virtual dispatch and all this rigidity, I think Formatter needs to be rethought a little. My preference obviously goes to satically-typed formatters. But what I'd like to see is something like this: interface Serializable(F) { void writeTo(F formatter); } Any object can implement a serialization for a given formatter by implementing the interface above parametrized with the formatter type.I like it. There needs to be some way to hold format-specific state info for a stream though. I guess this could be done via an external hash (stream address to formatter state), but it would be nicer if this could be stored in the stream itself somehow.
This design prevents new formatters from working with existing class hierarchies, unless they themselves obey a hierarchy which undoes the very advantage of the design.
It also forces the person defining a class hierarchy to statically commit to a specific formatter for the entire hierarchy.
As a corollary this design forces the designer of a hierarchy to make early and big decisions.
Andrei
