diff options
| author | Omar Rizwan <omar@omar.website> | 2022-12-15 18:41:55 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2022-12-15 18:41:55 +0000 |
| commit | 12c795569f72f637cf84fa54e7f1fb6f5e18d557 (patch) | |
| tree | 29757b3d85ae35323b79f7d1e76537dd1f207660 /virtual-programs | |
| parent | Fix finalization of collected matches (diff) | |
| download | folk-12c795569f72f637cf84fa54e7f1fb6f5e18d557.tar.gz folk-12c795569f72f637cf84fa54e7f1fb6f5e18d557.zip | |
Actually fix collected matches (incl disposal of old labels)
Use step count + end-of-convergence hook technique
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/with-all.folk | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/virtual-programs/with-all.folk b/virtual-programs/with-all.folk index 684a225f..6eb3a21e 100644 --- a/virtual-programs/with-all.folk +++ b/virtual-programs/with-all.folk @@ -1,12 +1,6 @@ Wish $this has filename "with-all.folk" set ::collectedMatches [dict create] -proc ::updateCollectedMatches {clause} { - set matches [dict get $::collectedMatches $clause] - Retract the collected matches for $clause are /something/ - Assert the collected matches for $clause are [dict keys $matches] - Step -} When /someone/ wishes to collect matches for /clause/ { set varNames [lmap word $clause {expr { [regexp {^/([^/ ]+)/$} $word -> varName] ? $varName : [continue] @@ -16,12 +10,21 @@ When /someone/ wishes to collect matches for /clause/ { foreach varName $varNames { dict set match $varName [set $varName] } dict set ::collectedMatches $clause $match true - ::updateCollectedMatches $clause On unmatch [subst { dict unset ::collectedMatches {$clause} {$match} - ::updateCollectedMatches {$clause} }] } + When $::nodename has step count /c/ { + On convergence [format { + set clause {%s} + set __matchId %d + if {[dict exists $Statements::matches $__matchId] && + [dict exists $::collectedMatches $clause]} { + set matches [dict get $::collectedMatches $clause] + Say the collected matches for $clause are [dict keys $matches] + } + } $clause $__matchId] + } On unmatch { dict unset ::collectedMatches $clause } } |
