[erlang-questions] Re: Special syntax for dictionaries

Robert Virding <>
Wed May 5 12:20:14 CEST 2010

The problem is that syntax has to be interpreted by two different
parsers: programmers who read the code and the language parser. While
programmers can often infer what you mean the parser can only follow
strict rules. This means that there can be no ambiguities.

While your examples might work if the value is a simple constant or
variable allowing any legal general expression will cause problems.
How would you interpret <{erlang:list_to_integer("123")}> ? Note that
white space is usually ignored so making white space significant here
would be creating a special case for just this. There is no difference
between erlang:list_to_integer and erlang : list_to_integer.

Even if you grab the first atom + colon as key name you can still get
some funny combinations, for example
<{erlang:erlang:list_to_integer("123")}>. The parser would have no
problems with this, it would blindly follow the rules, but a
programmer might start to wonder.

This was the main reason that = is used in the record syntax. While ~
may look strange using : will cause problems. How about =? Though this
may force you to parenthesize some expressions.


On 5 May 2010 09:32, Tim Fletcher <> wrote:
>> Would not using ":" make it look like a function call
>> (to another module)?
> Yes, if the values are atoms and you don't put spaces before/after the
> semicolon. Whilst that would be similar to a mod:fun call, there are
> no brackets, so technically there's no ambiguity. Currently that usage
> of the semicolon is illegal syntax, so presumably it could be made to
> work. And to make it really look like a function call you'd have to be
> using keys and values that are similar to those used to identify
> modules and functions, like this:
>  <{erlang:list_to_integer}>.
> I think both of these look sufficiently different from a mod:fun call
> though:
>  <{erlang: list_to_integer}>.
>  <{erlang : list_to_integer}>.
> Maybe it's my exposure to languages that use the semicolon for this
> purpose, but it feels more natural than "~".
> Tim
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:

More information about the erlang-questions mailing list