[erlang-questions] Tuples Vs Maps

zxq9 zxq9@REDACTED
Wed Sep 16 07:39:23 CEST 2015

On Wednesday 16 September 2015 10:41:31 Avinash Dhumane wrote:
> I find it more expressive to use maps wherever I have been using tuples.
> Especially, when it comes to pattern matching.
> It is precise to put #{some_key := some_value} instead of {_, _, _,
> {some_key, some_value}, _, _} as a pattern.
> I only fear efficiency of maps over tuples, in particular the time-cost,
> not so much of space-cost.
> How safe will I be if I resort to use only maps freely everywhere?

Not sure what you mean by "safety". That could mean a lot of things.

In any case, the syntactic difference you referenced calls for records, not maps.

Records are a special syntax over tuples, losing none of the speed. Maps are Key:Value stores with generally good lookup times (but make it more annoying than lists of tuples to look up a Key from a known Value). The use cases can overlap occasionally, but more often than not are *made* to overlap arbitrarily when one's mind gets stuck in one mode of thinking or the other.


More information about the erlang-questions mailing list