From f752a0e252e217660467ebcc412ddc62495a260c Mon Sep 17 00:00:00 2001 From: user Date: Sun, 15 Dec 2019 08:16:43 -0800 Subject: phone work --- starts/meaning-vm/habit-starts/learning-parts.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'starts/meaning-vm/habit-starts') 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 -- cgit v1.2.3