Typed callbacks for more robust behaviours

  • Authors:
  • Stavros Aronis;Konstantinos Sagonas

  • Affiliations:
  • School of Electrical and Computer Engineering, National Technical University of Athens, Greece, Athens, Greece;School of Electrical and Computer Engineering, National Technical University of Athens, Greece, Athens, Greece

  • Venue:
  • Proceedings of the 10th ACM SIGPLAN workshop on Erlang
  • Year:
  • 2011

Quantified Score

Hi-index 0.00

Visualization

Abstract

Behaviours are one of the most widely used features of Erlang/OTP. They offer a convenient and well-tested abstraction layer for frequently employed design patterns in concurrent Erlang programming. In effect, they allow programmers to focus on the functional characteristics of their applications without having to resort to Erlang's concurrency-supporting primitives. However, when it comes to ensuring that behaviours are properly used and callbacks are as expected, the current Erlang/OTP compiler performs only minimal checks. This is no fault of the compiler though, because most/all of the callbacks' API exists only in the documentation or the comments accompanying the code; as such, it cannot always be trusted and it is almost impossible to have it mechanically processed. In this paper, we propose a small extension to the language of function specifications of Erlang to allow the formal definition of the behaviours' callback API. We have implemented this extension on the development branch of Erlang/OTP and provide evidence of how it can be leveraged by static analysis tools such as Dialyzer to detect behaviour misuses.