Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stdlib] Add an option for thousands separator to package "format" #186

Open
trs123 opened this issue May 24, 2021 · 0 comments
Open

[stdlib] Add an option for thousands separator to package "format" #186

trs123 opened this issue May 24, 2021 · 0 comments

Comments

@trs123
Copy link

trs123 commented May 24, 2021

The primitive Format from stdlib's package "format" should allow for formatting with thousands separators, e.g. "10,000,000" instead of "10000000".

Note
Of course the thousands separator should be language dependent (and I just learned that even the grouping is language/culture dependent) but i18n seems not supported yet by Pony. I assume that currently the package "format" uses "." as decimal separator and therefore could use "," as grouping separator with a grouping of 3 digits for now (thousands separator). To allow more freedom the thousands separator to be used could be provided instead.

Proposal
The basic function Format.apply() could by extended with a new parameter separator (or maybe sep as Pony APIs seem to prefer abbreviated variable names):

"""
...
* sep. The character to be used as thousands separator.
"""
fun apply(
    str: String,
    fmt: FormatDefault = FormatDefault,
    prefix: PrefixDefault = PrefixDefault,
    prec: USize = -1,
    width: USize = 0,
    align: Align = AlignLeft,
    fill: U32 = ' ',
    sep: (U32 | None) = None)
    : String iso^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants