[plt-scheme] question about lift-strict in frtime

From: Gregory Cooper (ghcooper at gmail.com)
Date: Wed Jul 22 02:23:44 EDT 2009

Hi Chongkai,

Data constructors in FrTime do not implicitly propagate reactivity
(they are not "lifted"), so, for example, (list 1 seconds) evaluates
not to a behavior but to a list containing a behavior:

(list 1 seconds) : List[Bhvr[Integer]]

Although structures with behaviors "nested" in them like this are
important, it doesn't really make sense to apply "lift-strict" to
them.  (They're not behaviors, and projecting their current values has
no effect.)  Instead, for lifting you typically want a value where all
the reactivity has been "raised" to the top level.  There are two ways
to accomplish this:

1. Create data with lifted constructor applications, as you've done.
2. Apply "raise-reactivity" to data before "lift-strict"ing a procedure over it.

However, for normal use, lifting is only really intended for
procedures that consume simple data.  Thus I'd prefer another option
altogether, which is to define any such structure-consuming procedures
in FrTime instead of Scheme.  Then you shouldn't need to do any
lifting at all...


On Tue, Jul 21, 2009 at 8:06 PM, Chongkai Zhu<czhu at cs.utah.edu> wrote:
> Hi All,
> When working with lift-strict in frtime with ordinary Scheme primitives that
> take list/vector as input, I find it working only when I use "lift-strict
> list" and "lift-strict vector" to build the data. When using just
> "list"/"vector" or quasi-quote and unquote, it just doesn't work. The
> attached file shows the problem. This is with DrScheme, version 4.2 under
> Windows. Did I do something wrong, or is it a bug?
> Thanks,
> Chongkai
> (require "test1.ss")
> ;works
> (lift-strict myadd1 (lift-strict list 1 seconds))
> (lift-strict myadd2 (lift-strict vector 1 seconds))
> `(1 ,seconds)
> (vector 1 seconds)
> ;doesn't work
> #|
> (lift-strict myadd1 (list 1 seconds))
> (lift-strict myadd1 `(1 ,seconds))
> (lift-strict myadd2 `#(1 ,seconds))
> (lift-strict myadd2 (vector 1 seconds))
> =>
> test1.ss:6:2: +: expects type <number> as 2nd argument, given:
> #(struct:signal ...
> |#
> #lang scheme/base
> (provide myadd1 myadd2)
> (define (myadd1 x)
>  (apply + x))
> (define (myadd2 x)
>  (apply + (vector->list x)))
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.