summaryrefslogtreecommitdiff
path: root/starts/meaning-vm
diff options
context:
space:
mode:
Diffstat (limited to 'starts/meaning-vm')
-rw-r--r--starts/meaning-vm/level-2/funcs.cpp4
-rw-r--r--starts/meaning-vm/level-2/funcs.hpp2
-rw-r--r--starts/meaning-vm/level-2/sugar.hpp5
-rw-r--r--starts/meaning-vm/makefile2
4 files changed, 6 insertions, 7 deletions
diff --git a/starts/meaning-vm/level-2/funcs.cpp b/starts/meaning-vm/level-2/funcs.cpp
index b17d221..3c34c41 100644
--- a/starts/meaning-vm/level-2/funcs.cpp
+++ b/starts/meaning-vm/level-2/funcs.cpp
@@ -17,7 +17,7 @@ ref context()
return ctx;
}
-ref makehabit(ref name, std::initializer_list<ref> argnames, std::function<void()> code)
+ref makehabit(ref name, std::initializer_list<ref> argnames, std::function<void(ref)> code)
{
ref habit = level1::a(habit, name);
ref posarg = habit;
@@ -46,7 +46,7 @@ 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 ret = habit.fun<ref>()(ref::context());
posarg = habit;
while (posarg.linked(next-positional-argument)) {
posarg = posarg[next-positional-argument];
diff --git a/starts/meaning-vm/level-2/funcs.hpp b/starts/meaning-vm/level-2/funcs.hpp
index 770ff0a..f32679c 100644
--- a/starts/meaning-vm/level-2/funcs.hpp
+++ b/starts/meaning-vm/level-2/funcs.hpp
@@ -9,7 +9,7 @@ namespace intellect {
namespace level2 {
ref context();
-ref makehabit(ref name, std::initializer_list<ref> argnames, std::function<void()> code);
+ref makehabit(ref name, std::initializer_list<ref> argnames, std::function<void(ref)> code);
ref dohabit(ref habit, std::initializer_list<ref> args);
}
diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp
index 3b0e2c0..e0dfcd9 100644
--- a/starts/meaning-vm/level-2/sugar.hpp
+++ b/starts/meaning-vm/level-2/sugar.hpp
@@ -24,15 +24,14 @@
intellect::level2::makehabit( \
name, \
{_macro_call(_macro_for_each_parens, _macro_habit_argnameref _macro_comma_remove_parens(argnametoklist))}, \
- (std::function<void()>) \
- [=]() \
+ (std::function<void(ref)>) \
+ [=](ref ctx) \
{ \
{ \
static int delay = (double(rand()) / RAND_MAX * 400000 + 200000); \
usleep(delay); \
} \
ref self = name; (void)self; \
- ref ctx = intellect::level2::ref::context(); (void) ctx;\
_macro_call(_macro_for_each_parens, _macro_habit_set_posarg _macro_comma_remove_parens(argnametoklist)); \
__VA_ARGS__ \
});
diff --git a/starts/meaning-vm/makefile b/starts/meaning-vm/makefile
index bd0d2bd..325a07c 100644
--- a/starts/meaning-vm/makefile
+++ b/starts/meaning-vm/makefile
@@ -15,7 +15,7 @@ habit-starts/rhythm: habit-starts/rhythm.o liblevel2.a
$(CXX) $(CXXFLAGS) -c $^ -o $@
%.ii: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -E $^ -o $@
-.INTERMEDIATE: $(patsubst %.cpp,%.ii,$(wildcard */*.cpp *.cpp))
+.INTERMEDIATE: $(patsubst %.cpp,%.ii,$(wildcard */*.cpp) $(wildcard *.cpp))
liblevel%.a: level-%/*.hpp
%.a: