Ranges - Question about desing choices

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 24 08:19:32 PDT 2015


On Mon, Aug 24, 2015 at 03:16:10PM +0000, Adam D. Ruppe via Digitalmars-d-learn wrote:
> On Monday, 24 August 2015 at 15:09:14 UTC, Michal Minich wrote:
> >What are the advantages of current design.
> 
> One advantage of the current design is you can statically determine if
> something is an infinite range by seeing if empty is a constant false.
> With your change, you could never be sure if something was infinite or
> not since popFront would just keep returning true.
> 
> It is also sometimes useful to see if something is empty without
> modifying it, like when doing a wrapper.
[...]

It's also useful in parsing algorithms to look at the current item in
the input without also consuming it.


T

-- 
Right now I'm having amnesia and deja vu at the same time. I think I've forgotten this before.


More information about the Digitalmars-d-learn mailing list