EScala is an extension of Scala programming language with support for events as attributes of objects. The support for events in EScala, combine the ideas of event-driven, aspect-oriented and functional-reactive programming.
Events are natural abstractions for describing interactive behavior, and the interfaces of objects. In conventional object-oriented languages events are usually modelled indirectly using some form of the Observer or the Publish-Subscribe pattern. For example, in Java libraries an object exposes events by providing a possibility to register so-called listener objects. In C# such pattern is supported directly in the language, by allowing to declare events as special class members. Despite their differences, in all these approaches the occurrences of events are defined imperatively by triggering them at the corresponding locations within the program.
EScala extends the idea of events as object members, as realized by C# events, with the possibility to define events declaratively by expressions over other events. The occurrences of an event can be defined by various set operations, such as union, intersection and difference, applied on the occurrences of other events. Events can be filtered by arbitrary conditions, the data attached to the events can be transformed by arbitrary functions. Event expressions make it possible to define events in terms of other events, at the lowest level relying on primitive events.
There are two kinds of primitive events in EScala: In addition to imperative events, which are defined by triggering, EScala also supports implicit events, which mark language-specific actions during the execution of a program, such as the beginning or the end of the execution of a method. Implicit events in ESCALA are analogous to join points in aspect-oriented languages.
EScala events are fully integrated with object-oriented features. An events is defined in the context of its owner object and can use their state and functionality in their definition. Events are inherited in subclasses, and the access to events is late-bound. Unlike typical aspect-oriented languages, EScala preserves object-oriented encapsulation and modular reasoning. Like in Java, classes can be compiled and loaded independently.
This is joint work with the ASCOLA Research Group