[LLVMdev] [cfe-dev] C++11 reverse iterators (was C++11 is here)

Chris Lattner sabre at nondot.org
Wed Mar 5 11:29:32 PST 2014


On Mar 4, 2014, at 11:08 PM, Duncan Exon Smith <dexonsmith at apple.com> wrote:

>> 
>> because this allows us to factor apart the different aspects of using ranges. It addresses the "<foo>_if" composition problem, the "<foo>_n" composition problem, etc. The solution requires us to bring value semantics to algorithms, what I think would be the best result of ranges in C++.
>> 
>> Second, I really don't want two different patterns, because I find it very hard to tell what is an algorithm and what isn't. Maybe "sliced" clearly isn't an algorithm, and "sort" clearly is, but "reversed" starts to blur the line. What about rotate? I have heard many argue that filter should be an accessor. If sort is an algorithm, than surely partition is. But partition is just the same as filter! I think it is all simpler if these all follow the same fundamental pattern.
> 
> You're right, it needs to somehow be clear.  I think one reasonable rule is "past participle" means adaptor, while "present tense" means algorithm.  (That's why "reversed" makes some sense to me.)  By that rule, I'd say reverse, filter and rotate are algorithms (mutating the input), but reversed, filtered and rotated are adaptors (providing a mutated view of the input).  If we're consistent it'll be clear.
> 

Guys, you seem to be going down the line of "inventing a new programming model here", not solving the immediate problems we need to solve in the code.  Defining new programming models is interesting, but I'd much rather keep the LLVM codebase simple and relatively obvious.  Working on the C++ model is more appropriate for communities like Boost.

-Chris 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140305/dc018b6e/attachment.html>


More information about the llvm-dev mailing list