summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/habit-starts
diff options
context:
space:
mode:
authoruser <user@localhost.localdomain>2019-12-15 08:16:43 -0800
committeruser <user@localhost.localdomain>2019-12-15 08:16:43 -0800
commitf752a0e252e217660467ebcc412ddc62495a260c (patch)
tree276f3612bc65ab4a50516ca3116a57da82bc8538 /starts/meaning-vm/habit-starts
parent3e65ec890f0bc9e9bec8ffd64e69ccf87ed6054e (diff)
downloadstandingwithresilience-f752a0e252e217660467ebcc412ddc62495a260c.tar.gz
standingwithresilience-f752a0e252e217660467ebcc412ddc62495a260c.zip
phone work
Diffstat (limited to 'starts/meaning-vm/habit-starts')
-rw-r--r--starts/meaning-vm/habit-starts/learning-parts.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/starts/meaning-vm/habit-starts/learning-parts.cpp b/starts/meaning-vm/habit-starts/learning-parts.cpp
index 2ff53b3..db65ffe 100644
--- a/starts/meaning-vm/habit-starts/learning-parts.cpp
+++ b/starts/meaning-vm/habit-starts/learning-parts.cpp
@@ -105,18 +105,29 @@ static int __init = ([]()->int{
// list-item has item
// item has action and context
ref i = li.get(item);
+ // i think below we are proposing that handlers
+ // take one context, which is the one prepared
+ // in the list, then we inject our context
+ // into that, inside a "happened" property.
+
i.get(action)(hapctx, i.get(action-context));
});
ahabit(whenever-habit, ((happens, ev), (action, act), (action-context, actctx)),
{
+ if ((action-context).linked(happened)) {
+ throw std::logic_error("happened on action-context");
+ }
if (!ev.linked(whenever-list)) {
ev.set(whenever-list, (make-list)(nothing));
}
+ ref list = ev.get(whenever-list);
// happens gets the list
ref item = a(whenever-action);
- item.link(
- (add-to-list)(
+ item.set(action, act);
+ item.set(action-context, actctx);
+
+ (add-to-list)(item, list);
// store ctx[action] on ctx[happens] as behavior to do
// store ctx[action-context] as context for behavior
// PROPOSE: automatically place [happened] inside [action-context] as a stub