summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-2/sugar.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'starts/meaning-vm/level-2/sugar.hpp')
-rw-r--r--starts/meaning-vm/level-2/sugar.hpp12
1 files changed, 9 insertions, 3 deletions
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<void(ref)>) \
[=](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 {