Re:[boost] Re:Re: Output formatters: different approaches

http://lists.boost.org/MailArchives/boost/msg71956.php Message: 2 Date: Fri, 01 Oct 2004 10:54:02 +0400 From: Vladimir Prus <ghost@cs.msu.su> Subject: Vladimir Prus wrote:
Robert, can I first of all ask you to use a mailer, or a news reader, which preserves threading? Recently experiments have shown that Mozilla Thunderbird, for example, works fine both with emails and with NTTP gateway, and it's free. You can also try some other clients, but please do something about the issue.
Hmmm - I've been trying to configure my MS Outlook to do this and its driving me crazy.
The idea of the library, as I see it, is to provide object serialization, but - without the overhead serialization library has - with extra layout tweaks
Yes, it would be nice.
For objects of the type being discussed, (i.e. no pointers, no class versioning, no memory tracking of duplicates, etc) the serialization library has no extra runtime overhead.
Basically, I want every call I define to have a 'dump' method which can be called from debugger. So, I need output facilities available in every translation unit.
If function output formatters is helpful for making output more easily presentable, fine. Though G. Rozenthal's, experiment makes me doubt this.
Which experiment?
I was referring to Rozenthals post: http://lists.boost.org/MailArchives/boost/msg71956.php [On the other hand, if output formatters is to be an alternative implementation of the functionality in the serialization library ]
I believe the demos and documentation in the serialization package show that it to be much, much easier to use than the proposed library for this purpose.
Robert, while I agree that serialization is immensely useful, the point you make above is a bit skewed. Which example in the serialization library shows how to change start/end delimiter of a vector?
That's what the xml_archive does for name-value pairs. The same method could be used for any user defined types. Robert Ramey

Robert Ramey wrote:
Robert, can I first of all ask you to use a mailer, or a news reader, which preserves threading? Recently experiments have shown that Mozilla Thunderbird, for example, works fine both with emails and with NTTP gateway, and it's free. You can also try some other clients, but please do something about the issue.
Hmmm - I've been trying to configure my MS Outlook to do this and its driving me crazy.
:-( I think Gennadiy has managed to convince Outlook to work fine over NNTP. Thunderbird works fine either way.
For objects of the type being discussed, (i.e. no pointers, no class versioning, no memory tracking of duplicates, etc) the serialization library has no extra runtime overhead.
Basically, I want every call I define to have a 'dump' method which can be called from debugger. So, I need output facilities available in every translation unit.
If function output formatters is helpful for making output more easily presentable, fine. Though G. Rozenthal's, experiment makes me doubt this.
Which experiment?
I was referring to Rozenthals post: http://lists.boost.org/MailArchives/boost/msg71956.php
And why that code makes you doubt that function output formatters are helpfull? Basically, he just implemented the same idea: formatter, which has some begin/end string and nested formatter for elements.
[On the other hand, if output formatters is to be an alternative implementation of the functionality in the serialization library ]
I believe the demos and documentation in the serialization package show that it to be much, much easier to use than the proposed library for this purpose.
Robert, while I agree that serialization is immensely useful, the point you make above is a bit skewed. Which example in the serialization library shows how to change start/end delimiter of a vector?
That's what the xml_archive does for name-value pairs. The same method could be used for any user defined types.
Could you be more specific. I don't know where in the code to look. Do you mean it's possible to change the separator used betwee name-value pairs? How? - Volodya

Hmmm - I've been trying to configure my MS Outlook to do this and its driving me crazy. :-( I think Gennadiy has managed to convince Outlook to work fine over NNTP. Thunderbird works fine either way.
OE actually.
For objects of the type being discussed, (i.e. no pointers, no class versioning, no memory tracking of duplicates, etc) the serialization library has no extra runtime overhead.
Basically, I want every call I define to have a 'dump' method which can be called from debugger. So, I need output facilities available in every translation unit.
If function output formatters is helpful for making output more easily presentable, fine. Though G. Rozenthal's, experiment makes me doubt this.
Which experiment?
I was referring to Rozenthals post: http://lists.boost.org/MailArchives/boost/msg71956.php
And why that code makes you doubt that function output formatters are helpfull? Basically, he just implemented the same idea: formatter, which has some begin/end string and nested formatter for elements.
Sorry, I am not exactly follow point you both are trying to make. But code was trying to prove that everything submitted library doing in regards to output (I am not interested in input any case) could be done in 200 line header without need for complex metaprogramming. I believe my example covers all possible formats that were discussed during review. Its hard to imagine that one would need something more that this code provides and that it generic enough to be covered by library. Would you want something like string format ("% | %") it could be easily added, though I question its usability. It assumes a lot of things when applied to multivalue container. As for reflection framework, I would be interested in generic solution, but again not in a context of output formatting specifically (I may use it for this purpose, but not design it for this purpose). Regards, Gennadiy.

Gennadiy Rozental wrote:
Which experiment?
I was referring to Rozenthals post: http://lists.boost.org/MailArchives/boost/msg71956.php
And why that code makes you doubt that function output formatters are helpfull? Basically, he just implemented the same idea: formatter, which has some begin/end string and nested formatter for elements.
Sorry, I am not exactly follow point you both are trying to make. But code was trying to prove that everything submitted library doing in regards to output (I am not interested in input any case) could be done in 200 line header without need for complex metaprogramming. I believe my example covers all possible formats that were discussed during review. Its hard to imagine that one would need something more that this code provides and that it generic enough to be covered by library.
When comparing your code and the proposed library, I have two points. First, the proposed one has a lot of code to detect what kind of object is output, for getting its elements, and so on. This adds a lot of complexity and should be avoided -- by using serialization library to do the task. Your implementation is indeed simple. But: it contains code which iterators over elements of a vector. Should I define my_cool_vector, I'd have to define an overload that your code can use. I'd prefer to defining only overload for serialization library, and have the output library use that automatically. Another point about your implementation is that it does not distinguish between sequences/maps -- which might be desirable.
Would you want something like string format ("% | %") it could be easily added, though I question its usability. It assumes a lot of things when applied to multivalue container. As for reflection framework, I would be interested in generic solution, but again not in a context of output formatting specifically (I may use it for this purpose, but not design it for this purpose).
What I'm proposing is that output library use the *existing* mechanism, provided by the serialization library. - Volodya

When comparing your code and the proposed library, I have two points.
First, the proposed one has a lot of code to detect what kind of object is output, for getting its elements, and so on. This adds a lot of complexity and should be avoided -- by using serialization library to do the task.
Ok. But I am not sure serialization library as it is now could be used for this purpose.
Your implementation is indeed simple. But: it contains code which iterators over elements of a vector. Should I define my_cool_vector, I'd have to define an overload that your code can use. I'd prefer to defining only overload for serialization library, and have the output library use that automatically.
Actually it's not exactly true. If you notice in a comment before void decorate_elements( std::ostream& ostr, std::vector<T> const& c, Decorator const& d ) I mention that it's actually supposed to be generic version that used for any class that match Collection concept, something like: enable_if<is_collection<T> > void decorate_elements( std::ostream& ostr, T const& c, Decorator const& d )
Another point about your implementation is that it does not distinguish between sequences/maps -- which might be desirable.
If you do want to distinguish you could do this with overloading like this enable_if<is_assoc_collection<T> > void decorate_elements( std::ostream& ostr, T const& c, Decorator const& d ) though I do not see an immediate need for this
Would you want something like string format ("% | %") it could be easily added, though I question its usability. It assumes a lot of things when applied to multivalue container. As for reflection framework, I would be interested in generic solution, but again not in a context of output formatting specifically (I may use it for this purpose, but not design it for this purpose).
What I'm proposing is that output library use the *existing* mechanism, provided by the serialization library.
I supposed you want to reuse namely reflection abilities of it. I am not quite sure existing mechanisms will allow you to supply convenient interfaces for most basic (but mostly used) cased.
- Volodya
Gennadiy. P.S. I did not have a chance yet to look on latest serialization library implementation, but here: http://article.gmane.org/gmane.comp.lib.boost.devel/78978 is my post dated somewhere in between two reviews, that describe traversing framework that could be used by serialization lib implementation and by ant other reflection need. I hope serialization library provide something like that. In this case We may use it for generic output formatting.
participants (3)
-
Gennadiy Rozental
-
Robert Ramey
-
Vladimir Prus