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

Chandler Carruth chandlerc at google.com
Mon Mar 3 10:29:17 PST 2014


On Mon, Mar 3, 2014 at 9:48 AM, Chris Lattner <sabre at nondot.org> wrote:

> In the best case 'get' doesn't really add any meaning, and in the worst
> case it is actively misleading
>
>
> It's getting the range though, just like Function::getArgumentList()
> returns the argument list.
>

I really disagree (and I disagree with getArgumentList for the same reason).

getFoo should return something with value semantics (even if its a const
reference to delay the copy). setFoo should directly mutate something.

What we're really doing is making the equivalent of a "member-like
accessor" method.


>
> For example, you might iterate over operands, and assign through the
> iterator to mutate them.
>
> Really, these operate as range-views over some sequence. It seems
> particularly easy to teach foo_begin(), foo_end() -> foos() as well.
>
>
> That's a very objective-c thing to do :-), they use the pattern foo() and
> setFoo() for the getter and setter, respectively (and the naming is baked
> into the property model).  I don't feel strongly against it, but we pretty
> consistently use the Java style 'get' prefix everywhere else.
>

If we have a setFoo, then I'm with you we should have a value-semantic
getFoo. But we have just plain "op_begin" and "op_end" and I think that
makes sense to extend to a range adaptor "operands".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140303/dfe89509/attachment.html>


More information about the cfe-dev mailing list