Because Elixir code is parsed into 3-tuples, there needs to be a different notation for an embedded 3-tuple. It is what I think of as “constructor” notation:
iex(12)> quote do: {1, 2, 3}
{:{}, [], [1, 2, 3]}
That’s true for other tuple lengths, which makes sense: why not be consistent?
Except for 2-tuples, which are represented unchanged:
iex(7)> quote do: {1, 2}
{1, 2}
My hunch is that’s because lists are unchanged:
iex(8)> quote do: [1, 2, 3]
[1, 2, 3]
… and making 2-tuples unchanged means that keyword lists are also unchanged:
iex(11)> quote do: [a: 1, b: 2]
[a: 1, b: 2]
I can’t think of a case where treating 2-tuples like other tuples would cause ambiguity, though. Is this just to make literal keyword lists more readable?
Maps also have a constructor representation:
iex(13)> quote do: %{a: 1}
{:%{}, [], [a: 1]}
Why is that needed?