TodePond / DreamBerd

perfect programming language
https://dreamberd.computer
Other
11.2k stars 342 forks source link

Can't use string interpolation in Switzerland #204

Open lunaneff opened 1 year ago

lunaneff commented 1 year ago

The Swiss franc doesn't have an official symbol like the dollar or euro do, and therefore DreamBerd can't be fully used in Switzerland. This issue is of special importance, as the Swiss franc is, according to Wikipedia, the 8th most traded currency, and the first on the list without a symbol.

Because it doesn't have a symbol, it's usually written using the ISO 4217 currency code: 12.35 CHF (CHF is sometimes also written before the value), or if it's in a context where the currency can be assumed (such as a physical store), one of these conventions is used depending on value:

We also can't fully agree on the decimal separator; some places use a dot, others use a comma.

Because of this, and because it likely also applies in other countries, I suggest the following syntax for string interpolation be added:

const const name = "world"!
print("Hello {name} CHF!")! // any ISO 4217 alphabetic currency code should work, whether numeric codes (such as 756 for CHF) should work is up for debate
print("Hello CHF {name}!")!
print("Hello {name}.-!")!
print("Hello -.{name}!")!
print("Hello {name}.{name}!")! // if the variable names differ, it should throw a syntax error

Each of these should print the string Hello world!.

Additionally, because smallest coin for the Swiss franc is worth 0.05 CHF, I'd suggest rounding the value to a multiple of 0.05 if the value is a float. Because I doubt we could agree on whether to round away from 0, towards 0, or to the nearest multiple, I suggest a compromise where we round left instead (what that means is up for debate).

For the implementation in #74, the full, up-to-date list of ISO 4217 currencies can be found at https://www.six-group.com/en/products-services/financial-information/data-standards.html, in both Excel and XML formats.

ItzSveno commented 1 year ago

+1

Bytestorm5 commented 1 year ago

Just popping in to say thanks for the link

ThePython10110 commented 1 month ago

I suggest a compromise where we round left instead (what that means is up for debate)

"Rounding up for debate." Does that imply that it will round up but people will debate about whether that's a good thing?