From cb833be05096cc3c19b97003dca58166caa9aeaa Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Sat, 26 Mar 2022 02:25:13 -0400 Subject: Create Always construct some notes on Vulkan in pi.tcl --- folk.tcl | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'folk.tcl') diff --git a/folk.tcl b/folk.tcl index 842cfb1e..5468e37b 100644 --- a/folk.tcl +++ b/folk.tcl @@ -1,7 +1,3 @@ -# a When Trace has -# - childWhenTraces -# - statements - proc Claim {args} { # TODO: get the caller instead of `someone` dict set ::statements [list someone claims {*}$args] true @@ -100,6 +96,10 @@ socket -server accept 4273 # With all /matches/ # To know when +set ::alwaysCbs [list] +proc Always {cb} { + lappend ::alwaysCbs $cb +} proc Step {cb} { # clear the statement set # TODO: support 'assumed'/'prelude' statements @@ -108,6 +108,7 @@ proc Step {cb} { set ::currentMatchStack [dict create] + foreach alwaysCb $::alwaysCbs {uplevel 1 $alwaysCb} uplevel 1 $cb # event: an incoming statement bundle @@ -122,15 +123,25 @@ proc Step {cb} { # (for now, draw all the graphics requests) } -# we probably don't need this -after 0 { Step {} } +Always { + When /rect/ is a rectangle with x /x/ y /y/ width /width/ height /height/ { + When /someone/ wishes $rect is highlighted /color/ { + # it's not really correct to just stick a side-effect in the + # When handler like this. but we did it in Realtalk, and it + # was ok, so whatever for now + Display::fillRect device $x $y [expr $x+$width] [expr $y+$height] $color + } + Wish $rect is highlighted $Display::blue + } -# on each frame { -# global fb black green + When /program/ has program code /code/ { + set this $program + eval $code + } +} -# # clear the screen -# fbFillScreen $fb $black -# } +# we probably don't need this +after 0 { Step {} } # With all matches -> clear screen, do rendering # or When unmatched -> clear that thing @@ -155,14 +166,6 @@ after 400 { Step { puts Step2 - When /rect/ is a rectangle with x /x/ y /y/ width /width/ height /height/ { - When /someone/ wishes $rect is highlighted /color/ { - # it's not really correct to just stick a side-effect in the - # When handler like this. but we did it in Realtalk, and it - # was ok, so whatever for now - Display::fillRect device $x $y [expr $x+$width] [expr $y+$height] $color - } - } Claim "rect1" is a rectangle with x 300 y 400 width 50 height 60 Wish "rect1" is highlighted $Display::green -- cgit v1.2.3