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.hpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp
index b44b282..9065a20 100644
--- a/starts/meaning-vm/level-2/sugar.hpp
+++ b/starts/meaning-vm/level-2/sugar.hpp
@@ -37,12 +37,18 @@
__VA_ARGS__ \
if (result != ref("nothing")) { ctx.link(ref("result"), result); } \
});
- #define _macro_habit_argnameref(name, tok) \
+ #define _macro_habit_argnameref(name, tok, ...) \
ref(#name)
- #define _macro_habit_commaargnameref(name, tok) \
+ #define _macro_habit_commaargnameref(name, tok, ...) \
, ref(#name)
- #define _macro_habit_set_posarg(name, tok) \
- ref tok = ctx[ref(#name)];
+ #define _macro_habit_set_posarg(name, tok, ...) \
+ if ((#__VA_ARGS__)[0] == 0 && !ctx.linked(ref(#name))) { \
+ throw an(ref("habit-context-missing-information")).link \
+ (ref("habit"), self, \
+ ref("context"), ctx, \
+ ref("missing-information"), ref(#name)); \
+ } \
+ ref tok = ctx.linked(ref(#name)) ? ctx[ref(#name)] : ref(#__VA_ARGS__);
// seed random number generator statically, for habit delay
namespace _macro_habit {