[erlang-questions] function clauses with maps (18.3)
Robert Virding
rvirding@REDACTED
Wed Mar 30 23:59:25 CEST 2016
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 <wallentin.dahlberg@REDACTED
> 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 <luis.azedo@REDACTED>:
>
>> 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 <
>> wallentin.dahlberg@REDACTED> 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 <luis.azedo@REDACTED>:
>>>
>>>> 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
>>>> erlang-questions@REDACTED
>>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>>
>>>>
>>>
>>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160330/ae99c678/attachment.htm>
More information about the erlang-questions
mailing list