summaryrefslogtreecommitdiffstats
path: root/folk.tcl
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2022-03-26 06:25:13 +0000
committerOmar Rizwan <omar@omar.website>2022-03-26 06:25:35 +0000
commitcb833be05096cc3c19b97003dca58166caa9aeaa (patch)
treedcb72e81621cd331c252b1cd813d20797134ce99 /folk.tcl
parentadd support for Save program (diff)
downloadfolk-cb833be05096cc3c19b97003dca58166caa9aeaa.tar.gz
folk-cb833be05096cc3c19b97003dca58166caa9aeaa.zip
Create Always construct
some notes on Vulkan in pi.tcl
Diffstat (limited to 'folk.tcl')
-rw-r--r--folk.tcl41
1 files changed, 22 insertions, 19 deletions
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