3 ms·
Behaviours might be what you're looking for, they're the closest thing to inheritance in Elixir. And you're absolutely right about genservers being objects :)
by POiNTx 3y ago
Behaviours might be what you're looking for, they're the closest thing to inheritance in Elixir.
And you're absolutely right about genservers being objects :)
- kimi 3y agoThey are, but it's not as natural as A specializes B that specializes C.
- toast0 3y agoIt's maybe not quite as formalized inheritance, but (at least in Erlang) you can make behavior B that is a behavior A, and in module C (which implements behavior B), do B:start(C, ...) B;start/? Most likely does A:start(B, ...) and when the callbacks come in, B may call functions from C or not depending on things (such as if there is an optional callback defined). If your boilerplate turns out to not really be that samey though, it's easier IMHO to have a template and customize it where applied.