You should be able to use inside matches if you make it a macro.

On Wed, Feb 8, 2017 at 02:28 Wojtek Mach <woj...@wojtekmach.pl> wrote:

> (sorry for digging up old topic)
>
> 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.
>
>
> Would the idea by that Elixir would allow doing a 13.0d sigil, and Decimal
> (whether in core or separate library) implements that sigil?
>
> I think another advantage of including Decimal in core is exactly the
> sigil. Then the inspect implementation could simply return "13.0d" instead
> of "#Decimal<13.0>" which would make it copy-pasteable in editor/iex (since
> it'd be a valid Elixir expression) which makes it extremely convenient for
> actually working with it, debugging code that uses it etc. Another
> advantage is using it is in match.
>
> Currently this isn't allowed:
>
> defmodule DecimalSigil do
>   def sigil_X(str, _) do
>     Decimal.new(str)
>   end
> end
>
> import DecimalSigil
> ~X[3] = Decimal.add(~X[1], ~X[2])
>
> cannot invoke remote function DecimalSigil.sigil_X/2 inside match
>
> # see: https://github.com/ericmj/decimal/issues/38
>
> Looks like custom sigils can't be used in matches, but built-in can.
>
> --
> 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/e5d1fc3e-14d9-489e-8051-2f7a7d2e913e%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/e5d1fc3e-14d9-489e-8051-2f7a7d2e913e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 


*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

-- 
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/CAGnRm4LwJuzCBWtf-abANDVbYeq4a4e4xRJbOmSrpqSCaX4vuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to