>
> My primary target application domain for adoption of Elixir is
> financial/logistics apps so being able to deal with currency and apply
> certain rounding rules and such is pretty key. Floating point is the
> devil when you do these things and most often you build something out
> of integers and track significant logical decimal places. Not being
> able to use these in guards is probably the most painful limit that I
> perceive right now.
>

The interesting thing is that, if you are dealing with money, you could
maybe implement your own Money type, possibly inspired by Decimal, and
provide sigils such as:

~m(10.00)USD


And money would also guarantee that you don't apply operations to different
currencies.

When it comes to operations, we have mentioned multiple options:

1. Use regular functions as in Decimal: number1 |> D.add(number2) |>
D.multiply(2)

2. Replace the current + and - and so on by operators that know how to use
money or decimal. Such will make regular + and - operators slower but it is
likely fine if you are applying it only to parts of your codebase.

3. Provide some sort of decimal evaluator: D.eval number1 + number2 *
number3

My long term wish is to actually provide decimal with unit support in the
standard library but, because we can't really make it really first class in
the standard library (i.e. we can't support it in guards), I still
personally feel it is better suited as a separated package. I would be open
though to adding support for number sigils like 13.0d, 13.0f although we
should also consider how numbers like rationals would play into that.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KPEW1CPv50Saji-r283xFaxwXTr2sRA10k72YgCsn%2BLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to