summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-2
diff options
context:
space:
mode:
authorolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-09 03:13:14 -0800
committerolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-09 03:13:14 -0800
commit584ca7f9b6fca6da54608d3b28274273b2c9a4b8 (patch)
treed553b549cf246ddb24c93f9a95467bf9e019c052 /starts/meaning-vm/level-2
parent8d238e65a88502b897f1944b7844afffdbc0d761 (diff)
downloadstandingwithresilience-584ca7f9b6fca6da54608d3b28274273b2c9a4b8.tar.gz
standingwithresilience-584ca7f9b6fca6da54608d3b28274273b2c9a4b8.zip
make level-2 have refs
Diffstat (limited to 'starts/meaning-vm/level-2')
-rw-r--r--starts/meaning-vm/level-2/baseref.hpp25
-rw-r--r--starts/meaning-vm/level-2/common.hpp1
-rw-r--r--starts/meaning-vm/level-2/concepts.hpp15
-rw-r--r--starts/meaning-vm/level-2/funcs.cpp15
-rw-r--r--starts/meaning-vm/level-2/funcs.hpp11
-rw-r--r--starts/meaning-vm/level-2/level-2.hpp3
-rw-r--r--starts/meaning-vm/level-2/ref.hpp15
-rw-r--r--starts/meaning-vm/level-2/sugar.hpp21
8 files changed, 105 insertions, 1 deletions
diff --git a/starts/meaning-vm/level-2/baseref.hpp b/starts/meaning-vm/level-2/baseref.hpp
new file mode 100644
index 0000000..c2bc0d1
--- /dev/null
+++ b/starts/meaning-vm/level-2/baseref.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "common.hpp"
+
+#include "funcs.hpp"
+
+#include "../level-1/common.hpp"
+
+#include <functional>
+
+namespace intellect {
+namespace level2 {
+
+template <typename ref>
+struct baseref : public level1::baseref<ref>
+{
+ using level1::template baseref<ref>::baseref;
+
+ // thread-local context
+ static ref context() { return level2::context(); }
+
+};
+
+}
+}
diff --git a/starts/meaning-vm/level-2/common.hpp b/starts/meaning-vm/level-2/common.hpp
new file mode 100644
index 0000000..6f70f09
--- /dev/null
+++ b/starts/meaning-vm/level-2/common.hpp
@@ -0,0 +1 @@
+#pragma once
diff --git a/starts/meaning-vm/level-2/concepts.hpp b/starts/meaning-vm/level-2/concepts.hpp
new file mode 100644
index 0000000..a8cfb0d
--- /dev/null
+++ b/starts/meaning-vm/level-2/concepts.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "ref.hpp"
+
+namespace intellect {
+namespace level2 {
+
+namespace concepts {
+
+static ref context("context");
+
+}
+
+}
+}
diff --git a/starts/meaning-vm/level-2/funcs.cpp b/starts/meaning-vm/level-2/funcs.cpp
new file mode 100644
index 0000000..4ee02a4
--- /dev/null
+++ b/starts/meaning-vm/level-2/funcs.cpp
@@ -0,0 +1,15 @@
+#include "funcs.hp"
+
+#include "../level-1/sugar.hpp"
+
+namespace intellect {
+namespace level2 {
+
+level2::ref context()
+{
+ static thread_local level1::ref ctx = level1::a("context");
+ return ctx;
+}
+
+}
+}
diff --git a/starts/meaning-vm/level-2/funcs.hpp b/starts/meaning-vm/level-2/funcs.hpp
new file mode 100644
index 0000000..52c041d
--- /dev/null
+++ b/starts/meaning-vm/level-2/funcs.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "common.hpp"
+
+namespace intellect {
+namespace level2 {
+
+ref context();
+
+}
+}
diff --git a/starts/meaning-vm/level-2/level-2.hpp b/starts/meaning-vm/level-2/level-2.hpp
index 29ab89e..7c7dd9a 100644
--- a/starts/meaning-vm/level-2/level-2.hpp
+++ b/starts/meaning-vm/level-2/level-2.hpp
@@ -1,3 +1,6 @@
#pragma once
+#include "common.hpp"
+#include "concepts.hpp"
#include "sugar.hpp"
+#include "ref.hpp"
diff --git a/starts/meaning-vm/level-2/ref.hpp b/starts/meaning-vm/level-2/ref.hpp
new file mode 100644
index 0000000..7a2d58d
--- /dev/null
+++ b/starts/meaning-vm/level-2/ref.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "common.hpp"
+#include "baseref.hpp"
+
+namespace intellect {
+namespace level2 {
+
+struct ref : public baseref<ref>
+{
+ using baseref<ref>::baseref;
+};
+
+}
+}
diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp
index 2fa9414..3e94c97 100644
--- a/starts/meaning-vm/level-2/sugar.hpp
+++ b/starts/meaning-vm/level-2/sugar.hpp
@@ -12,7 +12,7 @@
#define ahabit(name, ...) \
a(habit, name); \
(name).fun((std::function<ref(ref)>) \
- [=](ref ctx) \
+ [=](ref ctx) -> ref\
{ \
habitdelay; \
ref self = name; \
@@ -21,6 +21,25 @@
return intellect::level1::concepts::nothing; \
});
+// thinking on handling arguments with less boilerplate, more positional sugar
+// transfer argslist to a context for calling?
+// possibly transfer argslist to a function signature for the call
+// transfer context to the argslist for handling call
+// for each item of argslist, make a local variable, and set it to its value
+/*
+#define _positionalhabitarg(local, arg) \
+ ref local = ctx.get(arg);
+#define _ph
+
+#define apositionalhabit(name, argslist, ...) \
+ a(habit, name); \
+ (name).fun((std::function<ref(ref)>) \
+ [=](ref ctx) \
+ { \
+ \
+ });
+*/
+
// seed random number generator statically, for habitdelay
namespace __internal {
static struct timespec __tp;