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.

>From a language perspective, having the kind of numerical support that
Haskell provides for example, would be amazing but perhaps not so
likely. From an implementation perspective, my first inclination that
this is more of a limit of the BEAM environment upon which Elixir
depends, and might need to be made as an extension to Erlang first for
it to become a true first class citizen of Elixir, no?

What actually *is* a viable path for getting such a capability into core Elixir?

  -- Ben

On Thu, Jun 30, 2016 at 6:09 AM, José Valim
<[email protected]> wrote:
>> from https://github.com/ericmj/decimal
>>
>> iex> alias Decimal, as: D
>> nil
>> iex> D.add(D.new(6), D.new(7))
>> #Decimal<13>
>> iex> D.div(D.new(1), D.new(3))
>> #Decimal<0.333333333>
>
>
> I definitely agree it is non-ideal. One option would to at least add a sigil
> so we can create decimals without going through Decimal.new.
>
>> 6.75d + 7.293d
>>
>> 6.75d / 3.2d
>
>
> The issue with this is that we would make the + operator slower for regular
> operations AND it would still not be allowed in guards, as Norbert
> mentioned. This has been, as a matter of fact, the biggest blocker for
> adding Decimals to Elixir itself.
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2ByufavV2SKWpBPx0kiqbtS4CD%2BDn0adD8BHi%2BpZc6jxA%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CACo3ShhNUVO6JndWwS6LVc%3DC4N0x57hKtT92js94rc_e2Kw4iA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to