[erlang-questions] Maps

Loïc Hoguin essen@REDACTED
Sat May 11 11:46:26 CEST 2013


Here's a simplified snippet:

add_item(Player=#{ inventory => #{ ItemID => # { quantity = Q }}}, 
ItemID, ItemInfos) ->
     Player#{ inventory => #{ ItemID => #{ quantity => Q + 1 }}};
add_item(Player, ItemID, ItemInfos) ->
     Player#{ inventory => #{ ItemID => ItemInfos }}.

Pretty clear what this code is doing, the equivalent with functions 
leaves me scratching my head. This kind of syntax also allows you to get 
it right the first time a lot more often than with functions.

I need to do things like this for more than 500 different actions. 
There's not enough time in the world to do it with functions. That 
particular project is on hold until I can avoid wasting my time btw.

On 05/11/2013 01:01 AM, Robert Virding wrote:
> I am curious. Could you give me an example of how you would like to use the new syntax? Or a new syntax?
>
> Robert
>
> ----- Original Message -----
>> From: "Loïc Hoguin" <essen@REDACTED>
>>
>> On 05/11/2013 12:42 AM, Robert Virding wrote:
>>> For the dict alternative having a special syntax would give me very
>>> little
>>
>> You break my heart.
>>
>> It's the one thing that is important to me. I don't care about the
>> implementation speed at all.
>>
>> --
>> Loïc Hoguin
>> Erlang Cowboy
>> Nine Nines
>> http://ninenines.eu
>>


-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu



More information about the erlang-questions mailing list