[erlang-questions] Maps
Björn-Egil Dahlberg
wallentin.dahlberg@REDACTED
Wed May 15 00:05:58 CEST 2013
2013/5/14 Loïc Hoguin <essen@REDACTED>
> 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?
If you do, make sure to base it of erlang/eep master since Raimo did not
use my eep branch for some reason. But hopefully we will not forget to test
this anyhow =)
>
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130515/25440101/attachment.htm>
More information about the erlang-questions
mailing list