Open sharkdp opened 11 months ago
We could easily achieve this by setting unit k = 1000, but that would reduce the number of available one-character variable names even further.
This could be gated behind a config flag, but I don't know if it's worth polluting the config file for something like this.
Yeah, I rather think this should be a special parser feature, if we decide to implement it.
if it where a special parser feature what would happen when you do
let k = 3
20k
?
What immediately comes to mind is to make whitespace between the 20
and the k
significant, so 20k
would be 20_000
but 20 k
would be 60
. Admittedly though that doesn't seem ideal.
if it where a special parser feature what would happen when you do
let k = 3 20k
That is a good question. To avoid ambiguity, we would have to reserve the k
identifier in this case as well.
What immediately comes to mind is to make whitespace between the
20
and thek
significant
I'd rather not do that. Also, I like how we can just write things like 2π
or 2x
, so I would like to keep the possibility to have identifiers 'attached' to numbers directly.
Maybe it's best to abandon this idea for now. Users can simply set unit k = 1000
in their init.nbt
.
Please feel free to comment here if you think this should be reopened.
I'd rather not do that. Also, I like how we can just write things like 2π or 2x, so I would like to keep the possibility to have identifiers 'attached' to numbers directly.
I was thinking about only making it significant for k
, M
, etc, not for other identifiers. I do agree that it's not a very nice solution though.
I was thinking about only making it significant for
k
,M
, etc, not for other identifiers
right. I think it's a viable option. I really dislike syntactic quirks in other languages, so I think we should maybe try to avoid things that users might trip over. And only introduce special cases if we are certain that there is a huge advantage.
Since numbers cannot currently end in underscores, one option could be that _k
, _M
are the suffixes. So 20k
is 60, 20_k
is 20,000. Just a thought, not sure whether this is better enough than 20e3
to be worth it.
Thank you for the idea. That would be possible.
Just a thought, not sure whether this is better enough than
20e3
to be worth it.
Right. Let's maybe reopen this to collect a bit more feedback before we decide anything.
… to support inputs like
300k €
or20k people
?We could easily achieve this by setting
unit k = 1000
, but that would reduce the number of available one-character variable names even further.