diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-14 11:48:23 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-14 11:48:23 -0800 |
commit | 0a59d8631e2acb20601e72c6f79d7ce193633844 (patch) | |
tree | e8c1292049fd1c6d6b3702bb944d830fc5a9655d /starts/meaning-vm/level-2 | |
parent | ec53662abe09a3ee1502e6ee7042d4ee84f36d1c (diff) | |
download | standingwithresilience-0a59d8631e2acb20601e72c6f79d7ce193633844.tar.gz standingwithresilience-0a59d8631e2acb20601e72c6f79d7ce193633844.zip |
missing changes
Diffstat (limited to 'starts/meaning-vm/level-2')
-rw-r--r-- | starts/meaning-vm/level-2/concepts.hpp | 3 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/funcs.cpp | 9 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/sugar.hpp | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/starts/meaning-vm/level-2/concepts.hpp b/starts/meaning-vm/level-2/concepts.hpp index 3a6ac6b..8e9c145 100644 --- a/starts/meaning-vm/level-2/concepts.hpp +++ b/starts/meaning-vm/level-2/concepts.hpp @@ -7,11 +7,14 @@ namespace level2 { namespace concepts { +using level1::concepts::nothing; + static ref context("context"); static ref habit("habit"); static ref next("next"); static ref positional("positional"); static ref argument("argument"); +static ref result("result"); } diff --git a/starts/meaning-vm/level-2/funcs.cpp b/starts/meaning-vm/level-2/funcs.cpp index a8835f4..11b3184 100644 --- a/starts/meaning-vm/level-2/funcs.cpp +++ b/starts/meaning-vm/level-2/funcs.cpp @@ -46,13 +46,18 @@ ref dohabit(ref habit, std::initializer_list<ref> args) if (posarg.linked(next-positional-argument)) { throw std::invalid_argument("wrong number of arguments to habit"); } - ref ret = habit.fun<ref>()(ref::context()); + habit.fun<ref>()(ref::context()); posarg = habit; while (posarg.linked(next-positional-argument)) { posarg = posarg[next-positional-argument]; ref::context().unlink(posarg[argument]); } - return ret; + if (ref::context().linked(result)) { + ref ret = ref::context().get(result); + ref::context().unlink(result, ret); + return ret; + } + return nothing; } } diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp index bff945b..5b3b150 100644 --- a/starts/meaning-vm/level-2/sugar.hpp +++ b/starts/meaning-vm/level-2/sugar.hpp @@ -32,8 +32,10 @@ usleep(delay); \ } \ ref self = 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); } }); #define _macro_habit_argnameref(name, tok) \ ref(#name) |