[plt-scheme] Re: frtime qn - behaviour depending on evt & another behaviour

From: Gregory Cooper (ghcooper at gmail.com)
Date: Tue Jul 29 10:55:02 EDT 2008

Hi Harsha,

'Collect-b' appears to be working as expected, applying its
transformer each time 'evt' fires and yielding the following sequence
of values:

(+ a 100) => 110 [a = 10]
(+ a (+ a 100)) => 80 [a = -10]
(+ a (+ a (+ a 100))) => 130 [a = 10]

What values were you expecting to get, and why?

On the side: the intended use of collect-b is with a transformer that
operates on constants.  By manipulating behaviors in the transformer,
you create a behavior whose value ranges over other behaviors (a
second-order behavior).  Such values display like ordinary behaviors
in the REPL, but in general they won't work as expected.  To get back
to an ordinary behavior, you should instead use 'collect-e' and

(define b (switch (collect-e evt 100 (lambda (e old) (+ a old))) 100))

Since this seems to be a common source of confusion, it should
probably be an error for collect-b's transformer to produce a


On Tue, Jul 29, 2008 at 9:21 AM, harsha <harsha.v.r at gmail.com> wrote:
> no, actually the function is deliberately ignoring the value of e and
> using a.
>  the intention was that the behaviour b, should update every time evt
> fires but not actually use the value of evt directly.
>  instead b uses a, another behaviour. a in turn depends on evt. so, i
> was thinking that when evt fires, a's value will change, and b will
> use the new value of a when updating itself.
> this does happen, but the value changes in a strange way.
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.