I have only been using Erlang for about 2 months now, but for the project I'm working on we decided to use binaries as a
replacement for strings, mainly to avoid the bloat caused by Erlang's standard strings. I ended up writing a module for string operations on binaries, which I'm including attached in case someone is interested on it (the unit tests require EUnit from SVN).
<br><br>One thing that I was always doing when iterating over binaries is doing matches like the following one:<br><br><<Head:Offset/binary, Char, Tail/binary>><br><br>and the annoying thing is that I could never use pattern matching at the function level because the argument representing the offset could not be used within the pattern. The functions look like this:
<br><br>fun(Bin, Offset) -><br> [...]<br><br>I don't see a way out of this with Erlang's current argument evaluation rules, but I thought I should mention it.<br><br>I'd definitely like to be able to match binaries against regular expressions. Another thing I'd like to see is the inclusion of the binary_to_atom/1 function to avoid having to go through a list to convert an atom to a binary.
<br><br><br><div><span class="gmail_quote">On 11/13/07, <b class="gmail_sendername">Fredrik Svahn</b> <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Nov 13, 2007 10:27 PM, Joe Armstrong <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:<br>> 6 ++++ fix BIFs for regexp, searching binaries etc - so people stop winging<br><br>I guess I am one of the people whinging. :-)
<br><br>I have recently started writing an EEP on various operations on<br>binaries that I would like to see added in a support library (e.g.<br>searching for patterns/multipatterns, splitting by pattern, regex,<br>some of them might be suitable to implement as BIFs, but that is a
<br>later question). Is there someone else out there already working on<br>this?<br><br>If not, please let me know what opertaions you would like to be able<br>to do on binaries. Are there any design patterns or operations on
<br>binaries that you keep writing over and over again? Any code involving<br>binaries which could be written in a more elegant way with a support<br>function? Any operations which you feel would be suitable to implement<br>
as BIFs?<br><br>BR /Fredrik<br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:firstname.lastname@example.org">email@example.com</a><br><a href="http://www.erlang.org/mailman/listinfo/erlang-questions">