[erlang-questions] function clauses with maps (18.3)

Björn-Egil Dahlberg <>
Thu Mar 31 00:08:12 CEST 2016


You are being vague in your doubt. Do you mean it would impose a matching
order? Which it would.

2016-03-30 23:59 GMT+02:00 Robert Virding <>:

> Personally I think it would be very dubious to change it as you would be
> changing the meaning of matching for those variables.
>
> Robert
>
>
> On 30 March 2016 at 23:04, Björn-Egil Dahlberg <
> > wrote:
>
>> OTP 20.0 at the earliest. However, no definitive decision has been made
>> about when or even if.
>>
>> 2016-03-30 22:59 GMT+02:00 Luis Azedo <>:
>>
>>> Thanks for the reply.
>>>
>>> so in the future in should work, right ? do you know which
>>> version/release we should wait before testing this ?
>>>
>>> Thanks
>>>
>>>
>>> On Wed, Mar 30, 2016 at 9:54 PM, Björn-Egil Dahlberg <
>>> > wrote:
>>>
>>>> This is a current limitation with maps and bitsyntax. Variables has to
>>>> be bound before being used as an expression in a pattern.
>>>>
>>>> 2016-03-30 22:01 GMT+02:00 Luis Azedo <>:
>>>>
>>>>> Hi,
>>>>>
>>>>> this doesn't compile in 18.3. is it supposed to work with the maps
>>>>> spec ? maybe in a later release ?
>>>>>
>>>>> -spec my_match(atom(), atom(), map()) -> any().
>>>>> my_match(Classification, CarType, #{my_key := #{ Classification := #{
>>>>> <<"cars">> := #{ CarType := Map}}}}) ->
>>>>> ....
>>>>> variable 'Classification' is unbound
>>>>> variable 'CarType' is unbound
>>>>>
>>>>>
>>>>> this works but we're not taking advantage of function clauses.
>>>>>
>>>>> my_match(Classification, CarType, M ) ->
>>>>>     #{my_key := #{ Classification := #{ <<"cars">> := #{ CarType :=
>>>>> Map}}}} = M,
>>>>>     Map.
>>>>> ....
>>>>>
>>>>> TIA
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> erlang-questions mailing list
>>>>> 
>>>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>>>
>>>>>
>>>>
>>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160331/c1d7edde/attachment.html>


More information about the erlang-questions mailing list