On 2010-12-28 13:07:56 -0500, Sean Kelly <[email protected]> said:

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.

The 'F' formatter can be anything, it can be a class, a delegate, a struct (although for a struct you might want to pass it as 'ref')... so it *can* hold a state. Or am I missing something?

If we want to specify additional parameters to writeTo for a given formatter, such as a format string, then the Serializable interface template could introspect type F to find what additional arguments it wants writeTo to have.


--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to