Feasible Idea?: Range Tester

Jonathan M Davis jmdavisProg at gmx.com
Thu Mar 21 11:18:47 PDT 2013


On Thursday, March 21, 2013 13:52:12 Nick Sabalausky wrote:
> On Thu, 21 Mar 2013 13:48:54 -0400
> 
> Nick Sabalausky <SeeWebsiteToContactMe at semitwist.com> wrote:
> > - Calling popFront doesn't throw unless range is empty.
> > - Calling popFront on an empty range throws a RangeError.
> 
> Actually, I'm not certain about those two, but I know
> they're true if you just s/popFront/front/

There are no such requirements on ranges. popFront most definitely _can_ throw 
even if the range is non-empty (e.g. UTFException due to invalid UTF), and I'm 
not aware of any range in Phobos which currently throws a RangeError when 
trying to call popFront on an empty range. Normally, an assertion is used, and 
the range's behavior when popping an element from an empty range in release 
mode is undefined. But I could definitely see an argument for adopting the 
policy of having popFront throw RangeError when the range is empty.

- Jonathan M Davis


More information about the Digitalmars-d mailing list