On 2/28/13 6:29 AM, Jonathan M Davis wrote:
There's tons of stuff that's fine with forward ranges (though I seriously
question the viability of pure input ranges given how insanely limiting is to
be unable to save their state), but there's also plenty of stuff that needs
random access, and if you _really_ care about speed, there's a decent chance
that you need random access (if nothing else, to be able to pop off multiple
elements at a time). That doesn't necessarily mean that you're using an array,
but odds are whatever you're using wraps an array if it isn't one. I don't
think that there's much of anything which is random access without having an
array or pointer underneath the hood. Reading from a file, I'd be very inclined
to use something like MmFile or reading the whole file into an array rather
than trying to wrap in something that's a pure input range. They're just too
limiting.

I think this (and the long, long, long text above) is missing a point. The necessity here is defining new range primitives (such as lookahead), not force the existing range notions onto the needed functionality.

Again:

1. Port the blessed lexer as is to D already

2. Figure out what abstraction is needed for lexer's input

3. Reify that abstraction as an existing range type, a variation on an existing range type, or a new range type

Talking abstraction without concrete is a poor approach. Concrete first, abstraction extracted from it.


Andrei

Reply via email to