substring search api

Bryan O'Sullivan bos at serpentine.com
Tue Sep 18 15:34:21 EDT 2007


Jon Fairbairn wrote:

> I'm not familiar with Bytestrings so I'm probably out of my
> depth, but something that strikes me is that if you are
> returned an index to a large object like this, to use it as
> the offset it would have to be the offset from the beginning
> of the large object, which would cause the large object to
> be held in memory until the indexing/dropping expression is
> evaluated.

That would be the case if you intended to use the offset for subsequent 
operations on the prefix, but at least sometimes that's not what you 
need it for.  For example, if you want to report a parse error due to a 
truncated input stream, having the offset lets you say precisely where 
the error occurred, even though you won't be using the prefix for anything.

This use of an offset is allowed for in the machinery of Data.Binary, 
and I use it in some libraries on top.

	<b


More information about the Libraries mailing list