From: Bernd S. <ber...@in...> - 2007-05-24 11:59:54
|
At Thu, 24 May 2007 13:18:20 +0200, Andreas Leitner wrote: > KL_TEXT_OUTPUT_FILTER -- just having the forwarding bits, doing no > transformation at all > > KL_INDENTED_TEXT_OUTPUT_STREAM | _FILTER -- just containing the > indentation bits > > Your name is intuitive and conveys the idea very well though, so if we > decide to hide the filtering metaphor, that's fine with me. I fully agree, having the concept of output filter would be nice for many applications. In the long run, might even consider building a cluster of filters. > > Or should the indentation facility be part of KI_TEXT_OUTPUT_STREAM > > with an option to enable it or not? In fact we probably don't need > > an option, the fact that `indent' is never called (and hence > > `indentation' is kept to 0) should be enough. The questions are: > > is it acceptable to add 2 attributes to class KI_TEXT_OUTPUT_STREAM, > > and will the test to figure out that there is actually no indentation > > to be printed be noticeable in terms of performance? > > That would actually be nice, since you don't need to build a pipeline. > On the other hand, I think a pipeline is quite intuitive and easy to > build (once you know the pattern) and it spreads the functionality so > that KI_TEXT_OUTPUT_STREAM itself is more easy to understand. Hmm - I think we should keep interfaces small to make it easy to implement new output streams. Blowing up interfaces with indentation facilities seems wrong. Filters are the better way to go. > > Note your implementation is not bullet-proof. It won't work if we > > call `put_string' with an argument that contains newlines. Is that > > acceptable? If yes, it should be clearly stated. > > Yeah, that's a very good point. I made it a habit of never writing > manifest newlines so it is not an issue. Processing `put_string' for > newline is a potential performance problem. So I would opt for leaving > it like it is. You are absolutely right though, we should state it in > the header comment and maybe even in the indexing clause. Best would be if we can toogle replacing newlines in strings with 'put_string' on- and off. Also, if it is off, do we need a precondition in put_string to enforce that the string does not contain newlines? I would even vote for switching it on by default, because it is the little more universal (though less efficient) choice. Bernd |