Functional reactive programming (FRP) is a declarative
programming language that combines a notion of continuous,
time-varying behaviors with a notion of discrete, event-based
reactivity. In previous work we investigated key theoretical
properties of FRP but did not formally address the issue of cost. But
one of our goals is to use FRP in real-time applications. In these
applications, it is crucial that the cost of running programs be known
before hand. Ideally, this cost should also be fixed.
To address these concerns, we present Real-Time FRP (RT-FRP), a
statically typed language where the cost of each execution step is
bounded by a constant, and the space needed for running a program is
also constant. These two properties guarantee that RT-FRP can be
executed in real-time and in constant space, making it a suitable
model for programming real-time applications and embedded systems.
The syntax of RT-FRP is developed as restricted subset of that of FRP.
The exact restrictions are described using two novel concepts inspired
by the notion of tail recursion. Most but not all of our existing
programs fall in this restricted subset of FRP. We deal with the
balance through a mechanism to integrate RT-FRP with an external