[RFC] I/O and Buffer Range

Dmitry Olshansky dmitry.olsh at gmail.com
Sat Jan 4 02:37:02 PST 2014


04-Jan-2014 13:39, Brian Schott пишет:
> I've been rewriting a bit of the lexer in DScanner.
>
> https://github.com/Hackerpilot/Dscanner/blob/NewLexer/stdx/lexer.d
> (Ignore the "invariant" block. I've been trying to hunt down some
> unreelated memory corruption issue)

startsWith & peek could be implemented with proposed the lookahead, so 
overall buffer range looks fitting to your use case.

>
> One thing that I've found to be very useful is the ability to increment
> column or index counters inside of the lexer range's popFront method.

>I think that I'd end up using my own range type for arrays, but construct
> a lexer range on top of your buffer range for anything else.

I think it should be possible to wrap a buffer range and to add related 
accounting and simplify interface for your own use.

As an experiment I have a greatly simplified buffer range - it builds on 
top of forward range making it instantly compatible with the most of 
std.algorithm. The only problem at the moment is slightly worse 
performance with DMD (who cares) and that it segfaults with LDC (and 
this is a problem). Would be nice to test LDC first but I think I'll 
publish it anyway, stay tuned.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list