Right now if you use access on a list, it expects it to be a keyword and 
requires the value to be an atom.

I've tried to think of a reason why we couldn't support this in the 
language, but I haven't been able to. If the value being accessed is an 
`integer` it could get the item at that index, and if its an `atom` it 
could treat it as a keyword and get the value for that key.

`[1, 2, 3][0] -> 1`
`[foo: :bar][0] -> {:foo, :bar}`
`[foo: :bar][:foo] -> :bar`
`[1, 2, 3][:foo] -> not a keyword list error`

It was pointed out that perhaps we don't do this to express that indexing a 
list is not fast in Elixir like it is in other languages, but I'm not sure 
if that is sufficient reason IMO to leave out a typically very standard 
feature of lists.

Thoughts?

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/dc7b3c13-08c7-48e8-a338-fe409ca4202an%40googlegroups.com.

Reply via email to