[erlang-questions] Literal support for unary (1#XXXXXX...)

Max Bourinov bourinov@REDACTED
Sun Jun 2 21:26:08 CEST 2013


Hi Andrew,

How base 1 works? Could you explain to me please? Is it number or digits
after dash?

Best regards,
Max

Best regards,
Max



On Sun, Jun 2, 2013 at 11:22 PM, Andrew Pennebaker <
andrew.pennebaker@REDACTED> wrote:

> Could we extend the # integer syntax to support base 1? It would be cool
> if 1#11111111 worked, instead of doing this:
>
> $ erl
> Erlang R15B03 (erts-5.9.3.1) [source] [64-bit] [smp:2:2] [async-threads:0]
> [hipe] [kernel-poll:false] [dtrace]
>
> Eshell V5.9.3.1  (abort with ^G)
> 1> 2#1000.
> 8
> 2> 1#11111111.
> * 1: illegal base '1'
> 2> #11111111.
> * 1: syntax error before: 11111111
>
> To be sure, base 1 isn't used that often in practice. But neither is base
> 3, 13, or 37, so it seems a little strange why the range of base literals
> is [2, 36]. If we apply the principle of "least surprise", I think it would
> be a good idea to also accept base 1.
>
> At worst, this would add one more complexity step; if we can't use the
> current base conversion algorithm for base 1, then adding one more match
> case and summing the number of 1's to follow would be trivial enough to
> implement.
>
> What do you think?
>
> --
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.us
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130602/e638c015/attachment.htm>


More information about the erlang-questions mailing list