On Mon, 04 Oct 2010 11:10:53 -0400, Peter Alexander <[email protected]> wrote:

I must be missing something, because I don't really see the need
for this at all.

Why not just return the number of items added, and forget about
chaining? If you're worried about having to type the container's
identifier in over and over again, just use with(c) {...}, and if
you want to chain together multiple different ranges, just use
std.range.chain.

This works also.  It depends on your preference for style.

I personally find this much more pleasant:

auto numAdded = lengthChain(a).add(1,2,3).add(b).add(c[1..3]).delta;

than:

int numAdded = void;
with(a)
{
  auto olength = length;
  add(1,2,3);
  add(b);
  add(c[1..3]);
  numAdded = length - olength;
}

But you might not.

Is there any use case where these don't suffice?

Achieving it all with a single expression. You might not care whether that's possible, but I personally like it better. Whether it achieves much more than style points, I don't know. I'm guessing it might add a bit of bloat.

-Steve

Reply via email to