Skip to content

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

Open
@Yzrsah

Description

@Yzrsah

I've always wished I could write this:

{
    xScale: 15M,
    yScale: 100K,
    zScale: 2.5M,
}

Instead of this:

{
    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:

{
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions