[erlang-questions] binary_to_integer/1 and binary_to_float/1 and friends

Lukas Larsson lukas@REDACTED
Tue May 8 18:35:56 CEST 2012


Hi,

There is no need to write an EEP for this and we would appreciate a
patch in this area.

For consistency the solution should also have functions called
binary_to_integer/2, integer_to_binary/1,2 and float_to_binary/1 which
behave the same was as their list counterparts.

Lukas

On Mon, May 7, 2012 at 4:01 PM, José Valim <jose.valim@REDACTED> wrote:
> Can someone from the OTP team let me know if I need an EEP for this or if I
> should just send patches straight to erlang-patches? Thanks in advance.
>
>
> On Mon, Apr 30, 2012 at 7:47 PM, José Valim <jose.valim@REDACTED> wrote:
>>
>> At the beginning of this year, there was a discussion about how to
>> implement binary_to_integer/1 in Erlang.
>> There is a possible implementation for such function which is quite
>> trivial:
>>
>>     list_to_integer(binary_to_list(binary))
>>
>> However, it has the trade-off that it can't be used in guards (unless
>> defined in a macro) and there is an unnecessary conversion cost to list
>> (although the cost is small since both binary and list are likely small).
>>
>> With Riak, Cowboy and other tools pushing towards using binaries instead
>> of lists for strings, the need for such functions will become more and more
>> common.
>> Is there any chance we will see this as built-in functions and therefore
>> available in guards in R16?
>>
>> Thanks,
>>
>> José Valim
>> www.plataformatec.com.br
>> Founder and Lead Developer
>>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list