summaryrefslogtreecommitdiff
path: root/starts/meaning-vm
diff options
context:
space:
mode:
Diffstat (limited to 'starts/meaning-vm')
-rw-r--r--starts/meaning-vm/habit-starts/learning-parts.cpp17
-rw-r--r--starts/meaning-vm/level-0/baseref.hpp11
-rw-r--r--starts/meaning-vm/level-2/sugar.hpp2
3 files changed, 21 insertions, 9 deletions
diff --git a/starts/meaning-vm/habit-starts/learning-parts.cpp b/starts/meaning-vm/habit-starts/learning-parts.cpp
index 56c7ffa..85c92c9 100644
--- a/starts/meaning-vm/habit-starts/learning-parts.cpp
+++ b/starts/meaning-vm/habit-starts/learning-parts.cpp
@@ -64,12 +64,13 @@ static int __init = ([]()->int{
ahabit(unlink, ((source, s), (type, t), (target, dst, anything)),
{
if (dst == anything) {
- result = s.unlink(t);
+ s.unlink(t);
} else {
- result = s.unlink(t, dst);
+ s.unlink(t, dst);
}
});
+ decls(get, set);
ahabit(get, ((source, s), (type, t)),
{
result = s.get(t);
@@ -95,7 +96,7 @@ static int __init = ([]()->int{
if (c.linked(is, group)) {
throw an(already-in-group).link
(habit, self,
- context, ctx,
+ "context", ctx,
concept, c,
group, g);
}
@@ -124,8 +125,8 @@ static int __init = ([]()->int{
// need args and result for sequence
//ahabit(habit-sequence, ((
- decls(list, nothing, next, previous);
- decls(make, add, to, until, each, item, in, remove, from, somewhere);
+ decls(list, nothing, next, previous, first, last, entry);
+ decls(add, to, until, each, item, remove, from, somewhere);
// list functiona are habits because ordered-behavior
// would use a list
@@ -182,7 +183,7 @@ static int __init = ([]()->int{
result = get(e, item);
});
- ahabit(add-to-list, ((item, i), (list, l)),
+ ahabit(list-add, ((list, l), (item, i)),
{
ref prev = (list-last-item)(l);
ref li = (know-is-list-entry)(
@@ -203,11 +204,11 @@ static int __init = ([]()->int{
prev.set(next, li);
}
});
- ahabit(list-each-entry, ((list, l), (context, c), (action, a)),
+ ahabit(list-each-entry, ((list, l), (context, c), (action, act)),
{
ref cur = l.get(first-item);
while (cur != nothing && result == nothing) {
- result = a(cur, context);
+ result = act(cur, c);
cur = cur.get(next);
}
});
diff --git a/starts/meaning-vm/level-0/baseref.hpp b/starts/meaning-vm/level-0/baseref.hpp
index d20b22a..9244492 100644
--- a/starts/meaning-vm/level-0/baseref.hpp
+++ b/starts/meaning-vm/level-0/baseref.hpp
@@ -68,6 +68,17 @@ public:
concept*& ptr() { return p; }
concept* const & ptr() const { return p; }
+ operator level0::ref const &() const { return *reinterpret_cast<level0::ref*>(this); }
+ operator level1::ref const &() const { return *reinterpret_cast<level1::ref*>(this); }
+ operator level2::ref const &() const { return *reinterpret_cast<level2::ref*>(this); }
+ operator level3::ref const &() const { return *reinterpret_cast<level3::ref*>(this); }
+ operator level4::ref const &() const { return *reinterpret_cast<level4::ref*>(this); }
+ operator level5::ref const &() const { return *reinterpret_cast<level5::ref*>(this); }
+ operator level6::ref const &() const { return *reinterpret_cast<level6::ref*>(this); }
+ operator level7::ref const &() const { return *reinterpret_cast<level7::ref*>(this); }
+ operator level8::ref const &() const { return *reinterpret_cast<level8::ref*>(this); }
+ operator level9::ref const &() const { return *reinterpret_cast<level9::ref*>(this); }
+
operator level0::ref &() { return *reinterpret_cast<level0::ref*>(this); }
operator level1::ref &() { return *reinterpret_cast<level1::ref*>(this); }
operator level2::ref &() { return *reinterpret_cast<level2::ref*>(this); }
diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp
index e6d9ea4..adedaa9 100644
--- a/starts/meaning-vm/level-2/sugar.hpp
+++ b/starts/meaning-vm/level-2/sugar.hpp
@@ -25,7 +25,7 @@
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) \
+ [&](ref ctx) \
{ \
{ \
static int delay = (double(rand()) / RAND_MAX * 400000 + 200000); \