From e720dfea4d7b07cbeb5312dbfd6940fd7fa29633 Mon Sep 17 00:00:00 2001 From: olpc user Date: Sat, 21 Dec 2019 08:34:50 -0800 Subject: =S default assumptions for habit macro --- starts/meaning-vm/level-2/sugar.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'starts/meaning-vm/level-2/sugar.hpp') diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp index 9065a20..e6d9ea4 100644 --- a/starts/meaning-vm/level-2/sugar.hpp +++ b/starts/meaning-vm/level-2/sugar.hpp @@ -22,7 +22,7 @@ #define ahabit(name, argnametoklist, ...) \ intellect::level2::makehabit( \ - name, \ + ref(#name), \ {_macro_call(_macro_for_each_parens, _macro_habit_argnameref, _macro_habit_commaargnameref _macro_comma_remove_parens(argnametoklist))}, \ (std::function) \ [=](ref ctx) \ @@ -31,12 +31,16 @@ static int delay = (double(rand()) / RAND_MAX * 400000 + 200000); \ usleep(delay); \ } \ - ref self = name; (void)self; \ + ref self = ref(#name); (void)self; \ ref result("nothing"); (void)result; \ _macro_call(_macro_for_each_parens, _macro_habit_set_posarg, _macro_habit_set_posarg _macro_comma_remove_parens(argnametoklist)); \ __VA_ARGS__ \ if (result != ref("nothing")) { ctx.link(ref("result"), result); } \ - }); + }); \ + { \ + ref _macro_habit_name(#name); \ + _macro_call(_macro_for_each_parens, _macro_habit_assume, _macro_habit_assume _macro_comma_remove_parens(argnametoklist)) \ + } #define _macro_habit_argnameref(name, tok, ...) \ ref(#name) #define _macro_habit_commaargnameref(name, tok, ...) \ @@ -49,6 +53,8 @@ ref("missing-information"), ref(#name)); \ } \ ref tok = ctx.linked(ref(#name)) ? ctx[ref(#name)] : ref(#__VA_ARGS__); + #define _macro_habit_assume(info, tok, ...) \ + if ((#__VA_ARGS__)[0] != 0) { intellect::level2::habitassume(_macro_habit_name, ref(#info), ref(#__VA_ARGS__)); } // seed random number generator statically, for habit delay namespace _macro_habit { -- cgit v1.2.3