Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing interfaces in Erlang

How does one implement an interface in erlang? What is the structure of the modules or how is it setup?

I have a layered architecture and want to implement the interfaces in each layer. Allowing the layer which requires the below layer to handle some task to access or call for these tasks.

How would this interface module look in terms of functionality?

like image 242
some_id Avatar asked Nov 07 '10 20:11

some_id


1 Answers

An interface in the sense of a Java interface or an ML module signature does not exist in the dynamically typed Erlang world. You will have to document the behavior in a comment or provide a -spec contract for the dialyzer to look at.

In general, the best way to approach a language is by not presuming you can map your existing knowledge too much into it, unless you happen to know a language that is "close" in concepts. Languages close to Erlang are Prolog and Scheme. Farther out comes Python and Ruby, but their reliance on an OOP design puts them into the horizon. Anything statically typed, Ocaml, Haskell, Java, C#, C++ and so on are definitely beyond the horizon.

like image 90
I GIVE CRAP ANSWERS Avatar answered Oct 01 '22 20:10

I GIVE CRAP ANSWERS