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

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -