RE: [boost] Re: Re: Review of Daryle Walker's "More IO" librarybeginstoday, August 21, 2004.

Jonathan Turkaniswrote:
Haskell uses whitespace to associate code on the right of the whitespace with the code on the left. e.g. [haskell.hs] factorial x = fimpl x where fimpl 0 = 1 fimpl x = fimpl ( x - 1 ) * x power (x:xs) = power xs * x power [] = 1 [end] where [] is an empty list and (x:xs) is a list with x as the head and xs as the tail. In this example, fimpl is associated with factorial and is only visible in its scope. factorial and power (both patterns) are in global scope. When writing a Haskell lexer, you need to be aware of the number of space characters after a given new-line. Therefore, something like multi_skipper would be useful, but it would need to: [1] reset an internal nspace variable on recieving a new-line character, allowing read access to it by the lexer; [2] incrementing by n (where n=3,4 or 8) upon recieving a tab character; [3] incrementing by 1 when recieving a space character I am not sure how the above could be implemented using multi_skipper, but this is an example where the number of spaces is important. Another example would be in padding. For example, the TAR file format ensures that each file fills a number of blocks of 256 bytes, so you need to skip the remaining bytes at the end of each file. Regards, Reece _________________________________________________________________ Want to block unwanted pop-ups? Download the free MSN Toolbar now! http://toolbar.msn.co.uk/

"Reece Dunn" <msclrhd@hotmail.com> wrote in message:
Jonathan Turkanis wrote:
"Rob Stewart" <stewart@sig.com> wrote in message
Okay, I'm a bit embarrassed. Instead of voting to reject ios_form, multi_newer and multi_skipper I should have justed asked for a better rationale. You and Rob have convinced me that all Daryle's manipulators (with possible exception of ios_form) should be accepted. Here's a summary of the names and extensions I'd like to see: - multi_skipper, etc. I'd like these usages to be supported: cin >> skip_line >> ... // skip a line cin >> skip_lines(12) >> .. // skip 12 lines cin >> skip('c', 3) >> ... // skip 3 c's cin >> skip("hello world!") >> .. // skip given sequence cin >> skip_if(isalpha) // skip alphabetic characters cin >> skip_to(isalpha) // skip non-alphabetic characters - multi_newer, etc. cout << newline << ... // write a newline without flushing cout << newlines(7) << ... // write 7 newlines cout << repeat('c', 3) << ... // write 3 c's - ios_form, if it does what Rob described, it sounds okay. I'd like to see an explanation from Daryle, though. I have no idea what the name should be. Best Regards, Jonathan

From: "Jonathan Turkanis" <technews@kangaroologic.com>
Someone raised the issue of singular versus plural causing confusion, but since "skip_line" takes no arguments, and "skip_lines" takes arguments, there should be no problem.
cin >> skip('c', 3) >> ... // skip 3 c's cin >> skip("hello world!") >> .. // skip given sequence
Nice. This, too: cin >> skip('x') >> ... // skip one 'x'
cin >> skip_if(isalpha) // skip alphabetic characters cin >> skip_to(isalpha) // skip non-alphabetic characters
These are terrific ideas. Obviously, the argument should be a predicate of general form so that clients can make their own.
Again, the singular versus plural issue is moot given the distinct invocation syntax.
cout << repeat('c', 3) << ... // write 3 c's
A question was raised wrt "repeat." If that's a problem, I suggest these alternatives ("repeat" is the best, though): ditto copy (would be a problem as std::copy) replicate multiple multi It would be interesting to make "repeat" (or whatever) a class so that it could be used to generate a string, insert on a stream, be iterable, etc.: template <typename T> class ditto { public: typedef ... iterator; typedef ... const_iterator; ditto(T value, std::size_t const count_i); iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; std::string toString() const; template <class OutputStream> void insert(OutputStream & os_i) const; private: T value_; std::size_t count_; }; template <class OutputStream> OutputStream & operator <<(OutputStream & os_i, ditto const & value_i) { value_i.insert(os_i); return os_i; } -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;

"Rob Stewart" <stewart@sig.com> wrote in message news:200408311655.i7VGtfY13582@lawrencewelk.systems.susq.com...
I'm glad you agree.
Thanks.
That was what I was thinking.
A bit too cute, I think ;-)
copy (would be a problem as std::copy)
and would clash with boost::io::copy, if my iostreams library is accepted.
These are all on the right track, but none is as intuitive as 'repeat', I think. Do you think 'iterate' has too many connotations?
Thanks sounds good. Regards, Jonathan
participants (3)
-
Jonathan Turkanis
-
Reece Dunn
-
Rob Stewart