Proposal for SentinelInputRange

Peter Alexander peter.alexander.au at gmail.com
Thu Feb 28 01:19:42 PST 2013


On Thursday, 28 February 2013 at 01:12:19 UTC, Walter Bright 
wrote:
> Motivation:
> 1. easy conversion of C strings to ranges

This is already easy.

struct CString
{
     @property char front() { return *p; }
     void popFront() { ++p; }
     @property bool empty() const { return !*p; }
     char* p;
}

(Yep, rubbish implementation, missing save, constructors etc., 
but you get the idea).

> 2. necessary for a fast implementation of a lexer

This is very domain specific. Is a whole new range concept in the 
standard library necessary?

My worry here is that we are setting a precedent for adding new 
range concepts. If the only justification needed is that is saves 
a single operation in some niche area of computing then we are 
opening the door to a LOT of different range concepts.

Are there any other REAL uses for this other than in one line of 
a lexer implementation? I think inclusions into the standard 
library should require at least several distinct and realistic 
use cases.


More information about the Digitalmars-d mailing list