On 02.10.2011 21:06, Robert Jacques wrote:
On Sun, 02 Oct 2011 10:46:38 -0400, Dmitry Olshansky
<[email protected]> wrote:
On 02.10.2011 18:12, Martin Nowak wrote:
I've written a wrapper to promote input ranges to buffered forward
ranges.
It allows to write range agnostic lexers/parsers with infinite
lookahead.
Buffering is done through a singly linked list of memory blocks that are
reference counted.
Each saved range holds a reference to all future blocks.
Blocks are recycled when being no longer used.
https://gist.github.com/1257196
Like it, but one thing catches my eye - why use GC for blocks when the
whole thing is already refcounted? Straight malloc/free would be a
better fit. Certainly it may use an allocator when we have them.
Consider that the elements could contain pointers, etc.
Mmh.. You are right, I was thinking I/O as soon as I seen line about
lexers/parsers. Though it could be an optimization if hasIndirections!T
is false.
--
Dmitry Olshansky