syndicate-2017/racket/prospect/examples/example-meta-echo.rkt

28 lines
1.0 KiB
Racket
Raw Normal View History

2016-02-07 21:14:12 +00:00
#lang prospect
2016-02-12 03:26:53 +00:00
;; Test case for a historical bug in Syndicate.
2016-02-07 21:14:12 +00:00
;;
;; When the bug existed, this program received four SCN events in
2016-02-07 21:14:12 +00:00
;; total, whereas it should receive only two.
;;
2016-02-12 03:26:53 +00:00
;; While metamessages were "echo cancelled", and receivers only ever
;; got one copy of a sent metamessage no matter how many metas there
;; were, state changes were not. Issuing a quick enough "pulse" of
;; metaassertion while maintaining interest in it led to an "echo":
2016-02-07 21:14:12 +00:00
;; multiple receipts of the pulse.
;;
2016-02-12 03:26:53 +00:00
;; The fix was to adjust the implementation of state change
2016-02-07 21:14:12 +00:00
;; 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)))))