Access for tuples doesn't make sense, because in normal cases, you shouldn't use tuple as an iterative structure. Good style is to have it <= 3 elements, and usually you need to switch to Struct in this case. There is a use-case, when you want to have O(1) access and would use conversion from lists to tuples, but this is not a common use case, and still, can be quite easily achieved via Enums + access by index. So, we should not support non-idiomatic usage of tuples.
Accessing lists by n is also non-idiomatic, because usually, you work with a list mostly in aggregate-style - iterating, mapping over it, or working in head/tail style via recursion. Keywords lists are different, because they are mostly used on small amount of items and their use-case - find a value by key. Thus even having O(n) is ok for them. On Tuesday, June 28, 2016 at 2:06:15 AM UTC+2, Filip Haglund wrote: > > Access for Keywords are already O(n), just like access on lists would be. > Tuples would probably be O(1). > > On Monday, June 27, 2016 at 5:27:32 PM UTC+2, Louis Pop wrote: >> >> Hey >> >> I think adding the Access protocol to lists would imply that list >> indexing is efficient. We should be careful to steer new users away >> from techniques that are inefficient or not idiomatic. >> >> Cheers, >> Louis >> >> On 27 June 2016 at 16:22, Filip Haglund <[email protected]> wrote: >> > Would it hurt to add it? >> > >> > On Sunday, June 26, 2016 at 6:16:19 PM UTC+2, Filip Haglund wrote: >> >> >> >> Why aren't lists and tuples implementing `Access`? >> >> >> >> {:a, :b, :c}[1] == :b >> >> >> >> >> > -- >> > 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 [email protected]. >> > To view this discussion on the web visit >> > >> https://groups.google.com/d/msgid/elixir-lang-core/3042a07d-90c9-4c82-a3a4-579579d44a1a%40googlegroups.com. >> >> >> > For more options, visit https://groups.google.com/d/optout. >> > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/af619fc4-da36-4dbc-9e54-0e1666647d54%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
