Proposal: takeFront and takeBack
Tobias Pankrath
tobias at pankrath.net
Wed Jul 4 13:34:46 PDT 2012
> Yes. But the cost of copying the value and the cost of the
> exception are
> separate.
The argument is not about performance, it's about loosing values.
> Simply popping off the element could throw an exception (in the
> case
> of strings in D, you'll get a UTFException if the string is
> malformed). So,
> _regardless_ of whether you return an element, you potentially
> risk an
> exception being thrown (depending on the implementation of the
> container or
> range).
It's not the same.
> And so I think that exceptions are pretty much irrelevant to the
> discussion of whether returning an element from popFront is a
> good idea or
> not.
How would you implement an returning popFront for a generic
container that
does not leak values? It's not possible (at least in C++, not
sure in D), so it is relevant. Maybe it was not the prime reason,
but it is a good reason non the less.
More information about the Digitalmars-d
mailing list