The problem is doing so inside case, receive, etc:

case var do
  {:ok, ^map.foo} -> ...
  {:error, ^map.bar} -> ...
end

The only way to implement this is by reading the value before the case and
that would be counter intuitive.



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

On Wed, Dec 7, 2016 at 5:40 PM, Michał Muskała <[email protected]> wrote:

> Hello everybody,
>
> Today the hat/pin operator (^) only allows the variable as argument, but I
> think it would be completely valid for it to allow any expression. This
> feels like a natural extension, especially useful when dealing with map
> fields. The number of times I tried to write something like that, only to
> realise it will fail is "too damn high" :P
>
>     assert_received {:foo, ^map.foo}
>
> The obvious fix is to transform this into
>
>     foo = map.foo
>     assert_received {:foo, ^foo}
>
> But I wonder - couldn't this be done automatically by the compiler, to
> extract such things from the patterns in order to place them before the
> case expression? I could be missing something, especially around some
> semantic difference, but I though about this for some time, and couldn't
> see anything harmful.
>
> Michał.
>
> --
> 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/6B434A06-5482-4CB8-BB76-18403C89DA7F%40muskala.eu.
> 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/CAGnRm4%2BaeWEvvdunUQzmfM9askzsPCUtz0qoD23HU%2BowZ3TgPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to