[erlang-questions] Special syntax for dictionaries

Richard O'Keefe ok@REDACTED
Tue May 4 01:10:09 CEST 2010


On May 4, 2010, at 7:57 AM, Sergey Samokhin wrote:

> Hello!
>
> While reading turorials of how MongoDB documents are made in
> Python/Ruby, I saw one thing I ever wanted to have in Erlang:
>
> {"author": "Mike",
> "text": "My first blog post!",
> "tags": ["mongodb", "python", "pymongo"],
> "date": datetime.datetime.utcnow()}
>
> That is special syntax for dictionaries.

My proposal for 'frames' has been sitting around for years.
I would write that as
	<{ author ~ "Mike"
	 , text   ~ "My first blog post!"
	 , tags   ~ ["mongodb","python","pymongo"]
	 , date   ~ erlang:now()
	}>
but it's NOT a hashmap because it's NOT mutable, the keys
may only be atoms, and it's intended for fast matching of
groups of at most low dozens of entries, being a replacement
for -record, not dictionaries.  As a practical matter, it
is important to separate keys from values by something
other than : (module prefix), = (matching), or -> (function
arrow), and a lot of work at Xerox PARC used ~ .

Joe Armstrong has a similar proposal which he called 'proper
structs' that is only superficially different from mine, but
even older.  (Mine discusses implementation, which his does
not.  It is possible to get the space for a frame down to
the same as the space for the corresponding record in the
usual case.)
>



More information about the erlang-questions mailing list