cheptsov / AdvancedExpressionFolding

https://plugins.jetbrains.com/plugin/9320?pr=idea
141 stars 30 forks source link

BigDecimal and BigNumber literal G (like in Groovy) #14

Open stokito opened 7 years ago

stokito commented 7 years ago

Groovy has a cool feature that in my experience of development financial applications makes code more cleaner: decimal literal G for BigDecimal. http://docs.groovy-lang.org/next/html/documentation/core-syntax.html#_decimal_literals Instead of

new BigDecimal("1.0005").add(new BigDecimal(42.42))

show:

1.0005G + 42.42G
petteyg commented 7 years ago

While I usually dislike inventing new syntax when a working one already exists, G makes me think "giga", not "big". I'd rather see \u1e04, capital B with dot below (think B decimal).

stokito commented 7 years ago

Nice idea. Lets think more. I have this thought that might be useful to get right decision:

So it becomes hard to choice literal. But actually should we? Literals are needed to make your life easier when you write a code. But in your plugin you need to show the code. So I would like to propose you just to show BidDecimal and BigInteger as usual number:

new BigDecimal("1.0005").add(new BigDecimal(42.42))

is shown as:

1.0005 + 42.42

What do you think about this?

cheptsov commented 7 years ago

The latest EAP build supports basic things like

new BigDecimal("1.0005").add(new BigDecimal(42.42))

More complicated case are to be supported later:

new BigDecimal("1.0005").add(new BigDecimal(42.42)).multiply(new BigDecimal(1.0))