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

Richard A. O'Keefe ok@REDACTED
Tue Jun 4 04:43:13 CEST 2013


On 3/06/2013, at 7:22 AM, Andrew Pennebaker wrote:
> 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.

One problem is that base 1 intrinsically and necessarily violates the
principle of least surprise.  In base n, the legal digits are 0..(n-1).
So in base 1 the only legal digit should be 0 (and the only expressible
number zero).  But *instead* the only legal digit is 1 (and it is
dubious whether zero is/should be expressible at all.)

To allow zero to be expressible in base 1, perhaps we should take
/1#[01]+/ as the syntax for base 1?

Aside from "coolness" (hello, Avery!), what's the need for this?




More information about the erlang-questions mailing list