Feasible Idea?: Range Tester

Jonathan M Davis jmdavisProg at gmx.com
Thu Mar 21 18:55:10 PDT 2013


On Thursday, March 21, 2013 19:46:08 John Colvin wrote:
> On Thursday, 21 March 2013 at 18:19:00 UTC, Jonathan M Davis
> 
> wrote:
> > I could definitely see an argument for adopting the
> > policy of having popFront throw RangeError when the range is
> > empty.
> > 
> > - Jonathan M Davis
> 
> In release mode, assert expressions are removed. This would not
> be possible for throwing a RangeError, preventing a useful
> optimisation in well tested code.

A valid point as to why such a change in policy should not be made. 
Regardless, there's definitely no requirement right now that popFront throw 
RangeError when the range is empty. What Phobos normally does at this point is 
assert. Anything else would be a change that would have to be discussed, so 
specifically testing that a conformant range throws a RangeError from popFront 
when it's empty (as Nick was suggesting) would not be correct at this point.

- Jonathan M Davis


More information about the Digitalmars-d mailing list