Use field instead of set!.

This commit is contained in:
Tony Garnock-Jones 2016-08-21 08:42:45 -04:00
parent 3240f20d90
commit 56e893fac4
1 changed files with 4 additions and 6 deletions

View File

@ -17,16 +17,14 @@
(define (print-prompt) (define (print-prompt)
(printf "> ") (printf "> ")
(flush-output)) (flush-output))
(define reader-count 0) (actor (field [reader-count 0])
(define (generate-reader-id) (print-prompt)
(begin0 reader-count
(set! reader-count (+ reader-count 1))))
(actor (print-prompt)
(until (message (inbound (external-event e (list (? eof-object? _))))) (until (message (inbound (external-event e (list (? eof-object? _)))))
(on (message (inbound (external-event e (list (? bytes? $bs))))) (on (message (inbound (external-event e (list (? bytes? $bs)))))
(match (string-split (string-trim (bytes->string/utf-8 bs))) (match (string-split (string-trim (bytes->string/utf-8 bs)))
[(list "open" name) [(list "open" name)
(define reader-id (generate-reader-id)) (define reader-id (reader-count))
(reader-count (+ (reader-count) 1))
(actor (printf "Reader ~a opening file ~v.\n" reader-id name) (actor (printf "Reader ~a opening file ~v.\n" reader-id name)
(until (message `(stop-watching ,name)) (until (message `(stop-watching ,name))
(on (asserted (file name $contents)) (on (asserted (file name $contents))