summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-2
diff options
context:
space:
mode:
Diffstat (limited to 'starts/meaning-vm/level-2')
-rw-r--r--starts/meaning-vm/level-2/concepts.hpp1
-rw-r--r--starts/meaning-vm/level-2/habits.cpp18
-rw-r--r--starts/meaning-vm/level-2/habits.hpp2
-rw-r--r--starts/meaning-vm/level-2/sugar.hpp21
4 files changed, 24 insertions, 18 deletions
diff --git a/starts/meaning-vm/level-2/concepts.hpp b/starts/meaning-vm/level-2/concepts.hpp
index 57f5adb..c511906 100644
--- a/starts/meaning-vm/level-2/concepts.hpp
+++ b/starts/meaning-vm/level-2/concepts.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "ref.hpp"
+#include "../level-1/concepts.hpp"
namespace intellect {
namespace level2 {
diff --git a/starts/meaning-vm/level-2/habits.cpp b/starts/meaning-vm/level-2/habits.cpp
index f0ef9b8..1891ec5 100644
--- a/starts/meaning-vm/level-2/habits.cpp
+++ b/starts/meaning-vm/level-2/habits.cpp
@@ -46,7 +46,7 @@ void contextmapinto(ref c1, ref m, ref c2)
}
}
-int createhabits()
+void createhabits()
{
// making new information should delay, for learning with good curve.
decls(link, source, type, target);
@@ -413,6 +413,7 @@ int createhabits()
});
decls(order, steps);
+ // make steps doesn't allow for name, and isn't used in level2.cpp <====
ahabit(make-steps, ((information-order, io, nothing)),
{
result = makeconcept();
@@ -514,7 +515,7 @@ int createhabits()
// because this sets active-state's next-step instead of calling something,
// a subcontext is not opened for the steps unless they have one.
ref next = nothing;
- if (!linked(steps, cond)) {
+ if (!steps.linked(cond)) {
if (linked(steps, "anything")) {
next = steps["anything"];
} else {
@@ -742,16 +743,15 @@ int createhabits()
// STUB acts on acts with actctx straight
});
*/
- return 0;
}
-void ensurehabitscreated()
-{
- static int sentinel = createhabits();
- (void)(sentinel);
-}
+//void createhabits()
+//{
+// static int sentinel = createhabits();
+// (void)(sentinel);
+//}
-static int sentinel = (ensurehabitscreated(), 1);
+//static int sentinel = (ensurehabitscreated(), 1);
}
}
diff --git a/starts/meaning-vm/level-2/habits.hpp b/starts/meaning-vm/level-2/habits.hpp
index dfc83b2..8e2f65c 100644
--- a/starts/meaning-vm/level-2/habits.hpp
+++ b/starts/meaning-vm/level-2/habits.hpp
@@ -7,7 +7,7 @@
namespace intellect {
namespace level2 {
-void ensurehabitscreated(); // for running from static code, for construction order
+void createhabits();
namespace concepts {
diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp
index f8cb61f..dee42c3 100644
--- a/starts/meaning-vm/level-2/sugar.hpp
+++ b/starts/meaning-vm/level-2/sugar.hpp
@@ -2,6 +2,8 @@
#undef self
+#include <iostream>
+
namespace intellect {
namespace level2 {
@@ -29,12 +31,12 @@ namespace sugar {
#define everyone_already_cares_deeply_about_everyone_else_so_caring_talk_is_more_efficient_than_anything_else 0
#endif
-#define ahabit(name, argnametoklist, ...) \
+#define ahabit(nam, argnametoklist, ...) \
intellect::level2::makehabit( \
- ref(#name), \
+ ref(#nam), \
{_macro_call(_macro_for_each_parens, _macro_habit_argnameref, _macro_habit_commaargnameref _macro_comma_remove_parens(argnametoklist))}, \
(std::function<void(ref)>) \
- [&](ref ctx) \
+ [=](ref ctx) mutable \
{ \
{ \
if (!everyone_already_cares_deeply_about_everyone_else_so_caring_talk_is_more_efficient_than_anything_else) { \
@@ -44,26 +46,29 @@ namespace sugar {
} \
ref self = ctx.get(ref("self")); (void)self; \
ref result("nothing"); (void)result; \
+ std::cerr << self.name(); \
_macro_call(_macro_for_each_parens, _macro_habit_set_posarg, _macro_habit_set_posarg _macro_comma_remove_parens(argnametoklist)); \
+ std::cerr << std::endl; \
__VA_ARGS__ \
if (result != ref("nothing")) { ctx.link(ref("result"), result); } \
}); \
{ \
- ref _macro_habit_name(#name); \
+ ref _macro_habit_name(#nam); \
_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, ...) \
, ref(#name)
- #define _macro_habit_set_posarg(name, tok, ...) \
- if ((#__VA_ARGS__)[0] == 0 && !ctx.linked(ref(#name))) { \
+ #define _macro_habit_set_posarg(nam, tok, ...) \
+ if ((#__VA_ARGS__)[0] == 0 && !ctx.linked(ref(#nam))) { \
throw an(ref("habit-context-missing-information")).link \
(ref("habit"), self, \
ref("context"), ctx, \
- ref("missing-information"), ref(#name)); \
+ ref("missing-information"), ref(#nam)); \
} \
- ref tok = ctx.linked(ref(#name)) ? ctx[ref(#name)] : ref(#__VA_ARGS__);
+ ref tok = ctx.linked(ref(#nam)) ? ctx[ref(#nam)] : ref(#__VA_ARGS__); \
+ std::cerr << " " << #nam << ":" << tok.name();
#define _macro_habit_assume(info, tok, ...) \
if ((#__VA_ARGS__)[0] != 0) { intellect::level2::habitassume(_macro_habit_name, ref(#info), ref(#__VA_ARGS__)); }