[erlang-questions] Accessing a single value from MAPS

Richard Carlsson <>
Thu Oct 8 14:37:04 CEST 2015


Not quite. The end-of-form (or 'dot') token requires that the period
character is followed by whitespace, a comment, or end-of-file. Otherwise
it's a '.' token, as is already in use in expressions like
Record#recordname.fieldname.

Once upon a time there was a special syntax called Mnemosyne for writing
Mnesia queries. To support this, the general form Expr.field was included
in the grammar (but only had a meaning within a Mnemosyne query). The
"packages" dotted namespaces piggy-backed on this grammar rule, and when
packages were removed, this rule was also removed (since Mnemosyne was no
longer supported either). But it could be put back and reused for maps. In
fact, I see that it temporarily _was_ used: see f00675d and 703a9aa.



        /Richard

On Thu, Oct 8, 2015 at 1:26 PM, Jesper Louis Andersen <
> wrote:

>
> On Wed, Oct 7, 2015 at 8:54 PM, Ivan Carmenates Garcia <
> > wrote:
>
>> Map.id, … would be nice!! instead of {id:= Id} = Map.
>
>
> The problem with using '.' here is that it is already taken for the
> 'end-of-expression' token. So the grammar becomes inconsistent if you use
> it for this purpose. You would have to pick some other signifier. You would
> have, e.g., Map#{id} be valid syntax meaning the value that is under 'id'
> (I think, the grammar might have trouble here as well).
>
>
> --
> J.
>
> _______________________________________________
> 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/20151008/81eff7f4/attachment.html>


More information about the erlang-questions mailing list