
Gennaro Prota wrote:
Hi Jeff,
just to be sure I understood: *the* two reasons for such a class are: (a) helping novices (b) having a cleaner (whatever that means) syntax.
Sorry if I'm missing something or oversimplifying the issue. It seems to me that (a) is a secondary point, as being a novice is something deemed to disappear asap if you want to seriously program in C++; (b)
Well that's too bad indeed, but I think you're wrong on this. For one thing, the committee is working changes for C++0x to fix long standing issues in C++ to eliminate common mistakes made by novices. Even so, I don't care *that much* about novices. I just want to be able to write code that *I* can understand when I read it 3 months later without rereading the string_algo and regex docs.
is very nicely obtained with Shunsuke's proposal, which seems to get the best of the two worlds: power and syntactical convenience
I'm unconvinced from what I've seen so far.
(BTW, Shunsuke, is the code in the vault?).
Seems unlikely given that it's a 'future proposal'. The only range algorithms stuff I know of in the vault was done by Eric N.
Other points?
Sure. Here's a sanitized fragment of a pretty typical form for a perl script I've probably written 100 times: open(IN, "<$filename") || die "File not found $filename\n"; $count = 0; while ($line = <IN>) { chomp($line); count++; if ($line =~ /^\*\*\*/) { $line =~ s/^\*\*\*//; $line .= " line: " . $count; do_something1($line); } elsif ($line =~ /^\*\*/) { $line =~ s/^\*\*//; do_something($line); } #...lots more... } I believe I can trivially rewrite this using super_string in C++. Due to the extra escape the regex's are harder to understand, but with some comments it should be easier to see what is happening then the perl: std::ifstream infile(...); super_string line; unsigned int count = 0; while (infile.getline(line)) { count++; line.trim_right(); if (line.contains_regex("^\\\*\\\*\\\*")) { line.replace_regex("^\\\*\\\*\\\*", ""); line.append( " line: ").append(count); do_something(line); } else {... I believe with some comments about what the regex's do, mere mortals (or Java programmers ;-) can read and understand this code. Why should it be any other way? Jeff