diff --git a/prospect-monolithic/examples/example-meta-echo.rkt b/prospect-monolithic/examples/example-meta-echo.rkt new file mode 100644 index 0000000..7f0eca3 --- /dev/null +++ b/prospect-monolithic/examples/example-meta-echo.rkt @@ -0,0 +1,27 @@ +#lang prospect-monolithic +;; Demonstrates a (hopefully soon historical!) bug in Syndicate. +;; +;; When the bug exists, this program receives four SCN events in +;; total, whereas it should receive only two. +;; +;; While metamessages are "echo cancelled", and receivers only ever +;; get one copy of a sent metamessage no matter how many metas there +;; are, state changes are not (yet). Issuing a quick enough "pulse" of +;; metaassertion while maintaining interest in it leads to an "echo": +;; multiple receipts of the pulse. +;; +;; The fix is to adjust the implementation of state change +;; notifications to cancel the echo for metaassertions. + +(require prospect/pretty) + +(spawn-network + (spawn (lambda (e counter) + (and e + (let ((new-counter (+ counter 1))) + (printf "Received event ~a:\n~a\n" new-counter (prospect-pretty-print->string e)) + (transition (+ counter 1) '())))) + 0 + (list (scn/union (assertion (at-meta 'x)) + (subscription 'x #:meta-level 1)) + (scn (subscription 'x #:meta-level 1))))) diff --git a/prospect/examples/example-meta-echo.rkt b/prospect/examples/example-meta-echo.rkt new file mode 100644 index 0000000..67d2efa --- /dev/null +++ b/prospect/examples/example-meta-echo.rkt @@ -0,0 +1,27 @@ +#lang prospect +;; Demonstrates a (hopefully soon historical!) bug in Syndicate. +;; +;; When the bug exists, this program receives four patch events in +;; total, whereas it should receive only two. +;; +;; While metamessages are "echo cancelled", and receivers only ever +;; get one copy of a sent metamessage no matter how many metas there +;; are, state changes are not (yet). Issuing a quick enough "pulse" of +;; metaassertion while maintaining interest in it leads to an "echo": +;; multiple receipts of the pulse. +;; +;; The fix is to adjust the implementation of state change +;; notifications to cancel the echo for metaassertions. + +(require prospect/pretty) + +(spawn-network + (spawn (lambda (e counter) + (and e + (let ((new-counter (+ counter 1))) + (printf "Received event ~a:\n~a\n" new-counter (prospect-pretty-print->string e)) + (transition (+ counter 1) '())))) + 0 + (list (patch-seq (assert (at-meta 'x)) + (sub 'x #:meta-level 1)) + (retract (at-meta 'x)))))