summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/habit-starts
diff options
context:
space:
mode:
authorolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-09 06:51:41 -0800
committerolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-09 06:51:41 -0800
commite6f2b95fb543b535b1914bd4954e240dbd724275 (patch)
treedcd081c1098489bc5c2172e5e535abb56094e763 /starts/meaning-vm/habit-starts
parent8ceeb5f83f22ed3db06fc02bb23710ccc1dbbb90 (diff)
downloadstandingwithresilience-e6f2b95fb543b535b1914bd4954e240dbd724275.tar.gz
standingwithresilience-e6f2b95fb543b535b1914bd4954e240dbd724275.zip
positional argument sugar for habits
Diffstat (limited to 'starts/meaning-vm/habit-starts')
-rw-r--r--starts/meaning-vm/habit-starts/rhythm.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/starts/meaning-vm/habit-starts/rhythm.cpp b/starts/meaning-vm/habit-starts/rhythm.cpp
index 7afb8ed..0877250 100644
--- a/starts/meaning-vm/habit-starts/rhythm.cpp
+++ b/starts/meaning-vm/habit-starts/rhythm.cpp
@@ -32,35 +32,34 @@ int main()
// next -> habit that follows
#undef self
- ahabit(next-habit,
+ ahabit(next-habit, (),
{
ref n = ctx[active-habit].get(next);
ctx.set(active-habit, n);
return n();
});
- ahabit(start-habit,
+ ahabit(start-habit, ((start,s)),
{
- ref s = ctx[start];
ctx.set(active-habit, s);
return s();
});
- ahabit(keep-doing-habit,
+ ahabit(keep-doing-habit, ((start,s)),
{
- (start-habit)();
+ (start-habit)(s);
while (true) {
(next-habit)();
}
});
- ahabit(start-beat,
+ ahabit(start-beat, (),
{
ctx.vset(beat, int(0));
self.set(next, wait-habit);
(beat-habit).set(next, wait-habit);
(wait-habit).set(next, beat-habit);
});
- ahabit(beat-habit,
+ ahabit(beat-habit, (),
{
int & b = ctx.vget<int>(beat);
char const * beats[] = {
@@ -118,12 +117,10 @@ int main()
std::cout << beats[b] << std::endl;
b = (b + 1) % (sizeof(beats) / sizeof(*beats));
});
- ahabit(wait-habit,
+ ahabit(wait-habit, (),
{
usleep(micros);
});
-
- ref::context().set(start, start-beat);
- (keep-doing-habit)();
+ (keep-doing-habit)(start-beat);
}