<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
There is currently no (good) way to get out of C-context to execute
some erlang snippet and then get back into c-context. Traps does
this but only in a controlled manner. I think it is doable though.<br>
<br>
Your proposal of maps_apply/3 is the maps equivalent of
dict:update/3 and sadly that name is already occupied in maps (it's
the equivalent of gb_trees).<br>
<br>
I think we should add it to the API without thinking about the
performance too much. Performance can always be improved later on.<br>
<br>
Is maps:apply/3 the best name we can think of? I don't really trust
you and naming things. =) update/3,4 would probably have been best
but c'est la vie.<br>
<br>
// Björn-Egil<br>
<br>
<div class="moz-cite-prefix">On 2016-04-13 13:09, Jesper Louis
Andersen wrote:<br>
</div>
<blockquote
cite="mid:CAGrdgiWpb4D4OyM-0qxcWBnMHi-9q-DPJ88fZNe+weMJ0NwiAQ@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<div dir="ltr">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Apr 8, 2016 at 8:31 PM,
Björn-Egil Dahlberg <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:wallentin.dahlberg@gmail.com"
target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:wallentin.dahlberg@gmail.com">wallentin.dahlberg@gmail.com</a></a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Have you
repeated some code or built your own private lib to handle
certain maps specific tasks and thought "why isn't this in
the maps module?"</blockquote>
</div>
<br>
</div>
<div class="gmail_extra">One function I like to have is "apply
update via function", and I implement it somewhat often:<br>
<br>
</div>
<div class="gmail_extra">maps_apply(F, K, Map) -><br>
</div>
<div class="gmail_extra"> V = maps:get(K, Map),<br>
</div>
<div class="gmail_extra"> maps:put(K, F(V), Map).<br>
<br>
</div>
<div class="gmail_extra">But it can be made much faster in a
direct implementation since I don't have to first pick up the
value: I can apply F when I sit with the value at hand and
thus avoid the "put" lookup path. It might, however, be nasty
to implement because F is in Erlang-context, whereas the maps
operations are in BIF-context.<br>
</div>
<div class="gmail_extra"><br clear="all">
<br>
-- <br>
<div class="gmail_signature">J.</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>