[plt-scheme] FrTime and sequential evaluation

From: Jaime Vargas (jev at mac.com)
Date: Sun Jul 6 16:52:01 EDT 2008

I have been playing with FrTime and I like it. However, I have a  
question.
How do I enforce sequential evaluation?

In the following code the procedurer count-down doesn't behave as
expected.

;;; Definitions window
(define elapsed (new-cell 0))

(define (tick)
     (- seconds
        (value-now seconds)))

(define (start-timer direction)
   (set-cell! elapsed (direction (value-now elapsed)
                                 (tick))))

(define (stop-timer)
   (set-cell! elapsed (value-now elapsed)))

(define (get-timer)
   elapsed)

(define reset-timer
   (case-lambda
     [(v) (set-cell! elapsed v)]
     [() (set-cell! elapsed 0)]))

(define (count-down v)
   (reset-timer v)
   (start-timer -))

(define (trigger-alarm)
   (when (= 0 elapsed)
     (stop-timer)
     "wake-up"))

;; Interactions window
 > (get-timer)
0
 > (count-down 10)

This starts counting down from 0, when I expected to count down from 10.

Thanks,

Jaime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080706/fe175d41/attachment.html>

Posted on the users mailing list.