summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorolpc user <olpc@xo-5d-f7-86.localdomain>2019-11-25 17:55:34 -0800
committerolpc user <olpc@xo-5d-f7-86.localdomain>2019-11-25 17:55:34 -0800
commitd4976b3e6fddec7a8ee010a6278e5cbe005542b4 (patch)
treeedb6c08843318dcefb4896eca141b7aeff1a78c6
parent59a4cccd495e925703dbbce74e733efd8e453f16 (diff)
downloadstandingwithresilience-d4976b3e6fddec7a8ee010a6278e5cbe005542b4.tar.gz
standingwithresilience-d4976b3e6fddec7a8ee010a6278e5cbe005542b4.zip
add batch linking via initializer_list, also some missing changes
-rw-r--r--starts/meaning-vm/DESIGN.txt16
-rw-r--r--starts/meaning-vm/level-0/baseref.hpp10
-rw-r--r--starts/meaning-vm/level-1/baseref.hpp2
-rw-r--r--starts/meaning-vm/level0.cpp8
-rw-r--r--starts/meaning-vm/level1.cpp39
-rw-r--r--starts/meaning-vm/makefile9
6 files changed, 58 insertions, 26 deletions
diff --git a/starts/meaning-vm/DESIGN.txt b/starts/meaning-vm/DESIGN.txt
index 036e6e4..80e446f 100644
--- a/starts/meaning-vm/DESIGN.txt
+++ b/starts/meaning-vm/DESIGN.txt
@@ -1,6 +1,20 @@
The codebase is made in levels.
Ideally each level defines a complete API to the underworkings.
-Higher levels include greater degrees of meaning.
+Higher levels include greater degrees of meaning and are
+more expressive and powerful.
+The purpose of levels is to prevent complexity recursion
+until the components are smart enough to adapt, and make
+handling bugs much less explosive.
+
+Levels have a 'ref' class they use to refer to concepts.
+Each higher level adds more functionality to this class.
+The desired norm of coding a level is to use only the
+functionality of the level prior, except to use that
+level's ref class, rather than the lower one. Ref classes
+are just wrappers for a pointer, so this should cause no
+issues.
+This norm was established after levels 0 and 1 were coded,
+so they do not meet it yet.
# LEVEL 0
Level 0 defines an interconnected network of concept references in memory.
diff --git a/starts/meaning-vm/level-0/baseref.hpp b/starts/meaning-vm/level-0/baseref.hpp
index b68de24..b4ceb02 100644
--- a/starts/meaning-vm/level-0/baseref.hpp
+++ b/starts/meaning-vm/level-0/baseref.hpp
@@ -36,6 +36,16 @@ public:
array getAll(ref const & type) const;
links_t links() const;
+ ref link(std::initializer_list<ref> refs)
+ {
+ for (auto it = refs.begin(); it != refs.end();) {
+ ref type = *it++;
+ ref target = *it++;
+ link(type, target);
+ }
+ return ptr();
+ }
+
template <typename T>
T& vget(ref const & type) const { return p->vget<T>(type.p)->data; }
template <typename T>
diff --git a/starts/meaning-vm/level-1/baseref.hpp b/starts/meaning-vm/level-1/baseref.hpp
index 01026c8..8c358cc 100644
--- a/starts/meaning-vm/level-1/baseref.hpp
+++ b/starts/meaning-vm/level-1/baseref.hpp
@@ -3,6 +3,8 @@
#include "common.hpp"
#include "funcs.hpp"
+#include "../level-0/ref.hpp"
+
namespace intellect {
namespace level1 {
diff --git a/starts/meaning-vm/level0.cpp b/starts/meaning-vm/level0.cpp
index 1dcc4f7..fa33d71 100644
--- a/starts/meaning-vm/level0.cpp
+++ b/starts/meaning-vm/level0.cpp
@@ -17,9 +17,11 @@ int main()
ref skip = alloc();
- a.set(b, c);
- a.link(d, e);
- e.link(b, a);
+ a.link({
+ b, c,
+ d, e
+ });
+ e.set(b, a);
c.link(b, e);
a.vset<int>(numlink, 3);
a.vset<std::function<void()>>(codelink, [](){
diff --git a/starts/meaning-vm/level1.cpp b/starts/meaning-vm/level1.cpp
index d6896b3..9dee4a7 100644
--- a/starts/meaning-vm/level1.cpp
+++ b/starts/meaning-vm/level1.cpp
@@ -12,26 +12,29 @@ int main()
decls(not, topic);
decls(A, B, C);
decls(source, type, target);
+ decls(structure, function, argument, position);
+ decls(variable, provide);
- (make-linked).set(is, habit);
- (make-linked).set(needs, []() -> ref {
- decls(structure, function, argument, position);
- decls(variable, A, B, C, provide);
-
- ref ret = a(structure);
- ret.link(is, function-argument);
- ret.set(argument-position, ref(1)),
- ret.set(a(variable, A), provide);
- ret.set(a(variable, B), provide);
- ret.set(a(variable, C), provide);
- return ret;
- }());
- movetoname(a(link), A-B-C-linked).set(link-source, A);
- (A-B-C-linked).set(link-type, B);
- (A-B-C-linked).set(link-target, C);
+ (make-linked).link({
+ is, habit,
+ needs, a(structure).link({
+ is, function-argument,
+ argument-position, ref(1),
+ a(variable, A), provide,
+ a(variable, B), provide,
+ a(variable, C), provide
+ })
+ });
+ movetoname(a(link), A-B-C-linked).link({
+ link-source, A,
+ link-type, B,
+ link-target, C
+ });
a(not, not-A-B-C-linked).set(topic, A-B-C-linked);
- (make-linked).set(assumes, not-A-B-C-linked);
- (make-linked).set(makes, A-B-C-linked);
+ (make-linked).link({
+ assumes, not-A-B-C-linked,
+ makes, A-B-C-linked
+ });
std::cout << (make-linked).dump("dumped", true) << std::endl;
diff --git a/starts/meaning-vm/makefile b/starts/meaning-vm/makefile
index d08f0b1..f1b4b12 100644
--- a/starts/meaning-vm/makefile
+++ b/starts/meaning-vm/makefile
@@ -4,13 +4,14 @@ LINK.o=$(LINK.cc)
all: level0 level1
level0: level0.o liblevel0.a
liblevel0.a: level-0/memorystore.o level-0/concept.o level-0/ref.o
-level1: level1.o liblevel0.a liblevel1.a
-liblevel1.a: level-1/ref.o level-1/sugar.o level-1/concepts.o
+level1: level1.o liblevel1.a liblevel0.a
+liblevel1.a: level-1/ref.o level-1/sugar.o level-1/concepts.o level-1/funcs.o
+liblevel%.a: level-%/*.hpp
%.a:
ar ru $@ $^
ranlib $@
-main: main.o concept.o helpers.o memorystore.o meaning.o
-*.o: *.hpp */*.hpp
+#main: main.o concept.o helpers.o memorystore.o meaning.o
+#*.o: *.hpp */*.hpp
clean:
-rm *.o main level0 level1 level2 *.a */*.o