Difference between protocol & behaviour in elixir -
Difference between protocol & behaviour in elixir -
behaviours define callbacks & protocols define methods without signatures. modules implementing protocol should give definition methods. same modules using behaviour. semantic difference?
one difference can think of is, protocol can implemented single type 1 time can implement behaviour module multiple times based on our requirements. clear when utilize what. there other difference other this?
protocol type/data based polymorphism. when phone call enum.each(foo, ...), concrete enumeration determined type of foo.
behaviour typeless plug-in mechanism. when phone call genserver.start(mymodule), explicitly pass mymodule plug-in, , generic code genserver phone call module when needed.
elixir
Comments
Post a Comment