google / google/jsonnet

Feature Request: K, M, B numerical suffixes for thousands, millions, billions

Open
#1,244 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Jsonnet
Stars
7.6k
Forks
475
PR merge metrics
No merged PRs in 30d

Description

I've always wished I could write this:
```jsonnet
{
xScale: 15M,
yScale: 100K,
zScale: 2.5M,
}
```

Instead of this:
```jsonnet
{
xScale: 15000000,
yScale: 100000,
zScale: 2500000,
}
```
It's just difficult to read, especially when there's more numbers. I have to stop and think kind of hard and look at the numbers carefully, and count the digits to make sure I'm not making a mistake.

Could do this:
```jsonnet
{
xScale: 15 * 1e6,
yScale: 100 * 1000,
zScale: 2.5 * 1e6,
}
```
But it's so verbose that I'd forget to use it.

It would be amazing if we could write numbers as simply as `100K`. I understand how this feature request might seem a little radical, but I think the purpose of the language is to describe information, and the feature scope of being able to describe information as `100K` is not all that different from `100 * 1000`.

Reasons this could work:
- It's forward compatible and wouldn't break any existing Jsonnet
- No ambiguity or parsing problems

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.