A library-based approach to context-dependent computation with reactive values: suppressing reactions of context-dependent functions using dynamic binding

Language constructs for programming context-dependent computation are required in recent software development, where context information influences program behavior, whose description is often scattered around several modules as conditional expressions. The Context-Oriented Programming (COP) community has revealed that context-dependent computations should be modularized into partially defined methods, those partial methods should be adaptable at run-time, and a method dispatching mechanism should take context information into account. Such language constructs enhance modularity of a program. Although contexts are usually reactively changeable, many existing COP approaches do not consider the relation between contexts and reactive information. In this paper, we develop a Scala library for context-dependent computations, based on the idea of contexts as reactive values, which are well studied in the field of Functional Reactive Programming. We also show that dynamic binding is useful to control how reactive values influence context dependent functions; it provides context caching to prevent unexpected reactions.

[1]  Amr Sabry,et al.  Delimited dynamic binding , 2006, ICFP '06.

[2]  Martin Odersky,et al.  Implementing first-class polymorphic delimited continuations by a type-directed selective CPS-transform , 2009, ICFP.

[3]  Paul Hudak,et al.  Functional reactive animation , 1997, ICFP '97.

[4]  Hidehiko Masuhara,et al.  Generalized layer activation mechanism through contexts and subscribers , 2015, MODULARITY.

[5]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[6]  Robert Hirschfeld,et al.  Declarative Layer Composition with The JCop Programming Language , 2013, J. Object Technol..

[7]  Wolfgang De Meuter,et al.  A survey on reactive programming , 2013, CSUR.

[8]  Robert Hirschfeld,et al.  Connecting Object Constraints with Context-oriented Programming: Scoping Constraints with Layers and Activating Layers with Constraints , 2015, COP@ECOOP.

[9]  Oscar Nierstrasz,et al.  Context-oriented programming: beyond layers , 2007, ICDL '07.

[10]  Hidehiko Masuhara,et al.  EventCJ: a context-oriented programming language with declarative event-based context transition , 2011, AOSD '11.

[11]  Michael Haupt,et al.  Event-Specific Software Composition in Context-Oriented Programming , 2010, SC@TOOLS.

[12]  Coen De Roover,et al.  Interruptible context-dependent executions: a fresh look at programming context-aware applications , 2012, Onward! 2012.

[13]  James O. Coplien,et al.  Lean Architecture: for Agile Software Development , 2010 .

[14]  Martin Odersky,et al.  Deprecating the Observer Pattern with Scala.React , 2012 .

[15]  Andry Rakotonirainy,et al.  Context-oriented programming , 2003, MobiDe '03.

[16]  Martin Odersky,et al.  Deprecating the Observer Pattern with Scala , 2012 .

[17]  Robert Hirschfeld,et al.  Language constructs for context-oriented programming: an overview of ContextL , 2005, DLS '05.

[18]  Olivier Danvy,et al.  Abstracting control , 1990, LISP and Functional Programming.

[19]  Kim Mens,et al.  Predicated generic functions: enabling context-dependent method dispatch , 2010 .

[20]  Mira Mezini,et al.  REScala: bridging between object-oriented and functional style in reactive applications , 2014, MODULARITY.

[21]  Kim Mens,et al.  Predicated Generic Functions , 2010, SC@TOOLS.