Open ds300 opened 7 years ago
sounds good, but I will unfortunately not have time to work on this
That's cool, huge thanks for all your work up to now! :1st_place_medal:
Hmmmm... thinking about this some more I'm not sure it makes sense to allow from
and until
in awake
coniditons because of cyclical situations that don't make sense like, if from
becomes truthy and then until
becomes truthy, but from
is still truthy, so does the reactor wake up again instantly? Anything else would be counter-intuitive, but then until
is still truthy and the reactor should go to sleep again instantly. And so on and so on.
This can't happen with the alive
condition because death is final.
So now I'm thinking the alive
condition should be programmable with a when
clause or from
and until
clauses, but the awake
condition should only be programmable with when
.
Reactors are like people—like almost any animal, actually—in that they are born and then they die, and during this time they can be either awake or asleep. When they are both alive and awake, they actively listen for and react to changes in their environment.
At the moment you define a birth date and death date for a reactor using the
from
anduntil
conditions, and you define a wake time and sleep time using thewhen
condition. These both declaratively describe spans of time, and yet they are not equivalent ways of doing that.from
anduntil
are more flexible thanwhen
for delimiting a span of time. The reactor becomes alive as soon as thefrom
condition is truthy. But then, no matter how thefrom
condition changes, the reactor stays alive until theuntil
condition becomes truthy (unless it was truthy to begin with, in which case the reactor never comes to life 😢 ).To illustrate, if we were to use the
when
condition for defining life-spans, the reactor would come to life when thewhen
condition becomes truthy and die when it becomes falsey.i.e.
is equivalent to
But if we introduce independent variables for
from
anduntil
:How can we convert that back to a
when
condition?when: foo.and(bar.not())
doesn't work becausefoo
could change back to a falsey value beforebar
becomes truthy. I think it is not possible to convert, because there is another implicit piece of atomic state which you cannot reference: the state of whetherfoo
has been truthy since the reactor was defined.So
{from: foo, until: bar}
is really equivalent to{when: fooHasBeenTruthyAtSomePoint.and(bar.not())}
So I think it should be possible to describe life-spans with a
when
condition, because sometimes that's convenient, and awake-spans withfrom
anduntil
conditions, because sometimes that's convenient.Here's the canonical format I propose:
But
when
will be allowed in thealive
orawake
time span descriptors, as a replacement for thefrom
anduntil
conditions.So far I haven't mentioned
skipFirst
andonce
from the existing scheme. Still thinking about that.