[erlang-questions] Maps

Dan Gudmundsson dgud@REDACTED
Tue May 14 17:17:11 CEST 2013


To summon up this thread with my view.

We want both Frames and Dictionaries.

Frames for it's small memory footprint and fast access, can replace records
except in the most
time critical places.

Dictionaries for it's arbitrary key terms and the ability to handle many
objects.

Matching is nice so we want have syntax to use them both, we do not want to
introduce two
new syntax's in the language because that will make it harder to read and
learn.

Fred Hebert
>  #{_ := V} = #{a => 3},
> and variants.

Value searching will not be allowed.

Richard A. O'Keefe
> Frames
>
Maps are basically an extension of Frames which allows for arbitrary key
terms.
Which could use your implementation proposal for small maps defined in
source code,
and switches to a tree (or something else) for larger dynamic sized Maps.

>- Frames are limited to atom keys in the interests of
> compile-time error detection (both simply noticing that
>  a key is not an atom at all and allowing the possibility
>  of Dialyzer support).

So use := and you will get a runtime/compile check that the key exists.

>- Frames have O(lg N) access to a single field or O(N/k) access
>  to k fields.  They have O(N/k) cost for copying a frame with
>  k fields changed.

You will still have that for small maps.

Robert Virding
> Use only matching

We would like to but we believe we can not do that because we can't output
a defined order,
i.e. you can not sort 1.0 and 1.
We would need to define a new term order in erlang and we need to introduce
something
like <:<, >:> =:< and >:=.

/Dan



On Tue, May 14, 2013 at 3:41 PM, Max Lapshin <max.lapshin@REDACTED> wrote:

> I think, that first problem is a convenient syntax for key-value
> structure. Syntax that will also work for pattern matching, not also
> editing existing structure.
>
> Second problem is a distinguishing between tuples and this special
> type. Many of us have problems trying to understand: is this a list of
> integers or a string? How should I pack it to json? As a result, many
> modern pieces of software are migrating to binary-only.
> _______________________________________________
> 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/20130514/c136aa4b/attachment.htm>


More information about the erlang-questions mailing list