[erlang-questions] Maps
Loïc Hoguin
essen@REDACTED
Tue May 14 23:48:38 CEST 2013
On 05/14/2013 11:04 PM, Björn-Egil Dahlberg wrote:
> It works fine if done in two steps (with the first step most likely
> done in the function clause itself).
>
> doit(M=#{ a := A=#{ b := B }}) ->
> M#{ a := A#{ b := B + 4 }}.
>
> Writing this I realize it's quite possible that you can already do
> it with the current EEP. Am I right?
>
>
> Yes.
>
>
> And it also fits:
>
> doit(M=#{ a := A=#{ b := B }, aa := yes_do_it}) ->
> M#{ a := A#{ b := B + 4 }, aa := done}.
>
> You can already do this with records. Can we do this with maps too?
> This + any type as key + dynamic is all I need.
>
>
> Yes. I had similar examples in the EEP but didn't nest the Maps.
Could be worth adding to the EEP so as to not forget to test it. Should
I send a PR to your repository?
> It would be cool if that could also be optimized at compile time,
> though that's more of an edge case so understandable if that comes
> later.
>
>
> What was it you said to me? "Make it work, make it pretty, make it
> fast." =) Still on step oneish.
Yep. It was just a suggestion that heavily hinted at "optimize for that
case after everything else is optimized".
--
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu
More information about the erlang-questions
mailing list