[erlang-questions] Maps

Björn-Egil Dahlberg wallentin.dahlberg@REDACTED
Fri May 17 11:11:25 CEST 2013


I like this idea of deep update, haven't look too closely though. :)

But please, discuss this in a separate thread.



// egil
Sent from my iPhone

17 maj 2013 kl. 10:58 skrev Vincent de Phily
<vincent.dephily@REDACTED>:

> On Thursday 16 May 2013 12:38:27 Loïc Hoguin wrote:
>> On 05/16/2013 07:43 AM, Richard A. O'Keefe wrote:
>>> Oddly enough, the EEP I've been working on (or at least Part 1, as I've
>>> split it into four parts) _is_ syntax decoupled from the implementation.
>>>
>>> Here's a copy of the current draft.  I'm about to go through the torture
>>> of adding Markdown, sigh.
>>
>> If I understand right, you need '#[]' defined in the local module, and
>> as such can only have one defined?
>>
>> This is going to be annoying when you want to use this syntax on both
>> records and JSON and some other structure in the same module.
>
>
> That worried me when reading the draft too. I expect that the answer is to
> define :
>> '#[]'({my_type, V}, K) -> extract_mytype(K,V);
>> '#[]'(Other, K) -> erlang_default:'#[]'(Other, K).
>
> But this can become ugly and unwieldy quickly. Perhaps we need a standard
> wraper function :
>> '#[]'(K,V,[]) -> erlang:error(badarg).
>> '#[]'(K,V,[M|T]) -> try M:'#[]'(K,V) catch error:badarg -> '#[]'(K,V,T).
>
> That we can use in each module as :
>> '#[]'(K,V) -> '#[]'(K,V,[mytype,json,maps,lists...]).
>
> But you need to order your modules very carefully, puting the most selective
> ones first.
>
>
>
> Appart from that, while this eep looks interesting, it doesn't seem to address
> pattern matching ? Or did I read incorrectly and you actually can
>> case Json of
>>    Json#['class']#['foo'] -> handle_foo(Json);
>>    Json#['class']#['bar'] -> handle_bar(Json);
>> end.
>
> ?
> --
> Vincent de Phily
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list