Neil Jerram <[email protected]> writes:

> IIRC, Metafont does that; but obviously it isn't intended as a general
> language.  Are there more general languages that solve equations like
> this?

>From what I know, Prolog.

Other than that, Scheme. ;)

Apart from David's FRP implementation, I worked on the following a
little:

https://gitorious.org/taylan-guile/reactive/

(Warning: I might force-push commits to that repo at times.  It's not
"ready for consumption.")

I don't consider it complete, and it might be broken.  Some simple
examples work:

guile> ,use (reactive base)
guile> (define x 0)
guile> (define v (make-value () x))
guile> (define v2 (make-value (v) (display "recalculated\n") (+ v 5)))
guile> (get/tainted v2)
recalculated
$2 = 5
guile> (get/tainted v2)
$3 = 5
guile> (set! x 1)
guile> (taint! v)
guile> (get/tainted v2)
recalculated
$4 = 6
guile>

As you see, it's not purely-functional, and it requires explicit
"tainting" of root values.  After that, though, requesting any value
which directly or indirectly depends on that root will ignite a
recalculation of the graph of dependent values up to the requested one.

I continuously get confused while trying to reason about the precise
behavior of this system (even though it's very small), and had grave
bugs in it at times (actually I just fixed one while writing this
because I did a wholesale clean-up on the repo and re-uploaded it at the
above link).  Therefore, please don't trust that module for "real"
usage.

Taylan

Reply via email to