Implementing interfaces in Erlang

前端 未结 2 1438
后悔当初
后悔当初 2021-02-14 23:24

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 interface

2条回答
  •  天命终不由人
    2021-02-15 00:13

    The closest concept in Erlang is user-defined behaviour. However, they tend to be used quite rarely. Note that the only thing which is checked is existence and arity of functions. You can't test that the module actually implements some behaviour; you just call the callback functions and if the module happens to "accidentally" export functions with same names, you are out of luck.

提交回复
热议问题