Why is Access a behaviour instead of a Protocol? When to use a Protocol instead of a Behaviour?

@michalmuskala: Now that Elixir always consolidates protocols during standard compilation, these performance issues have gone away, right?

Is there an “official” answer to this questions? I think it is quite valid.

I found this thread by trying to figure out the definitive differences between Behaviours and Protocols and looking at the implementation of Access, it seems to be perfectly fit to be implemented as a Protocol because it is all about polymorphism (e.g. Difference between protocol & behaviour in elixir - Stack Overflow).

I guess one could create an Access implementation as a Protocol, do measurements and see if anything has changed.

2 Likes