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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -