I'm a bit concerned about the performance impact and the fact that as
far as I can see the very basic & simple bitstring type would need to
change.
type bitstring = string * int * int
I'm using this tuple directly in quite a few places. It's also neat
and understandable for the common case. Because it doesn't contain
any functions, it can be marshalled too.
Isn't the best way to do this to add another type? Let's call it a
'bitstring_stream'. This would have to contain function callbacks
and whatever else is needed to handle streams.
The bitmatch operator cannot work directly with both a bitstring and a
bitstring_stream, so it needs some syntactic change, eg:
bitmatch_stream bits_ext with
| ...
and this allows us to generate slightly different code too. Thus no
performance penalty in the common case.
By the way, I also have another, kind of related request, for memory
maps, but I'll put that into another thread.
Rich.
--
Richard Jones
Red Hat
The question is then how much of the code can be factored between the
two ways of matching. Richard, do you have an idea on this point?
Cheers,
Samuel.
The hard part isn't defining the type, it's modifying the bitmatch
operator so it understands streams.
You'd definitely want to share code. The key would be to refactor
output_bitmatch[1] so that as much is shared as possible ...
It's a 400+ line monster function so I don't envy whoever gets to sit
down and write the patch.
Rich.
[1] http://code.google.com/p/bitstring/source/browse/trunk/pa_bitstring.ml#431
(sorry for delayed answer..)
Yes, indeed I came to that conclusion too.
Although I'm stil considering the idea to write another camlp4 extenstion to
implement my lazy string idea, I will try to have a look at output_bitmatch's
code when I have more time.
Probably not in the near future, since I have a lot of stuff to finish for
the end of this year...
R.