scala - Implementing snapshot in FRP -
i'm implementing frp framework in scala , seem have run problem. motivated thinking, question decided restrict public interface of framework behaviours evaluated in 'present' i.e.:
behaviour.at(now)
this falls in line conal's assumption in fran paper behaviours ever evaluated/sampled @ increasing times. restrict transformations on behaviours otherwise find ourselves in huge problems behaviours represent input:
val slider = stepper(0, sliderchangeevent)
with behaviour, evaluating future values incorrect , evaluating past values require unbounded amount of memory (all occurrences used in 'slider' event have stored).
i having trouble specification 'snapshot' operation on behaviours given restriction. problem best explained example (using slider mentioned above):
val event = mouseb // event occurs when mouse pressed val sampler = slider.snapshot(event) val stepper = stepper(0, sampler)
my problem here if 'mouseb' event has occurred when code executed current value of 'stepper' last 'sample' of 'slider' (the value @ time last occurrence occurred). if time of last occurrence in past consequently end evaluating 'slider' using past time breaks rule set above (and original assumption). can see couple of ways solve this:
- we 'record' past (keep hold of past occurrences in event) allowing evaluation of behaviours past times (using unbounded amount of memory)
- we modify 'snapshot' take time argument ("sample after time") , enforce that time >=
- in more wacky move, restrict creation of frp objects initial setup of program somehow , start processing events/input after setup complete
i not implement 'sample' or remove 'stepper'/'switcher' (but don't want either of these things). has thoughts on this? have misunderstood here?
oh see mean now.
your "you can sample @ 'now'" restriction isn't tight enough, think. needs bit stronger avoid looking past. since using environmental conception of now
, define behavior construction functions in terms of (so long now
cannot advance mere execution of definitions, which, per last answer, messy). example:
stepper(i,e)
behavior valuei
in interval[now,e1]
(wheree1
time of first occurrence ofe
afternow
), , value of recent occurrence ofe
afterward.
with semantics, prediction value of stepper
got conundrum dismantled, , stepper have value 0. don't know whether semantics desirable you, seems natural enough me.
Comments
Post a Comment