Live-coding two pages with Hoot's REPL

Two RealTalk pages, each with its own code printed (well, typed) below. Drag the cards onto the table to activate them. Edit either textarea and hit Run to swap in new code: the engine retracts whatever the old code had Claimed and runs the new code in its place.

Eval'd code runs in (realtalk)'s scope — Claim, Wish, When, get-page, set-background! are all in reach without imports. this inside the body refers to the page's own id.

Output:

Things to try

With both cards on the table, try replacing page 1's body with:

(Claim this 'highlighted "deepskyblue")

Or have page 1 claim more than one fact:

(Claim this 'highlighted "lavender") (Claim this 'wants-border #t)

Or replace page 2's rule to be selective:

(When ((?p highlighted ?color)) do (if (string=? ?color "yellow") (set-background! (get-page ?p) ?color)))

Or react to page 1's second claim:

(When ((?p wants-border #t)) do (set-attribute! (get-page ?p) "style" "border: 5px dashed red"))

Drag a card off the table and watch the engine retract its claims: rules that depended on them stop firing, and on the next fixpoint the visuals reset because recalculate-pages wipes the DOM and re-derives it from whatever facts remain.

Direct mutations like (set-background! (get-page this) "pink") inside a page body run once and then get wiped by the next reset — that's by design. Always write Claims for facts you want to persist, and let rules do the drawing.

Home