aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-16 16:38:15 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-16 16:38:15 -0800
commit1cbf9f3e07de9303283c747f7dbad61b77278819 (patch)
treec925f9a3c08d7a6eaceac33b585e52416628103d
parent2daebbff27b72c3cbae02a7cb12a4df141425784 (diff)
Moved things into core/
-rw-r--r--lib/core/init.nom1
-rw-r--r--lib/core/things.nom (renamed from lib/things.nom)35
2 files changed, 19 insertions, 17 deletions
diff --git a/lib/core/init.nom b/lib/core/init.nom
index 1319c5f..263c1d9 100644
--- a/lib/core/init.nom
+++ b/lib/core/init.nom
@@ -10,3 +10,4 @@ export "core/math"
export "core/id"
export "core/io"
export "core/text"
+export "core/things"
diff --git a/lib/things.nom b/lib/core/things.nom
index 9ca7e7d..c52eb5d 100644
--- a/lib/things.nom
+++ b/lib/core/things.nom
@@ -1,18 +1,23 @@
#!/usr/bin/env nomsu -V6.15.13.8
#
A library for simple object oriented programming.
-
+
+use "core/metaprogramming"
+use "core/operators"
+use "core/control_flow"
+use "core/collections"
+use "core/errors"
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
test:
an (Empty) is a thing
a (Buffer) is a thing:
$its.is_a_buffer = (yes)
($its, set up) means:
$its.bits or= []
- ($it, as text) means
- $it.bits, joined
- [($its, add $bit), ($its, append $bit)] all mean:
- $its.bits, add $bit
-
+ ($it, as text) means ($it.bits, joined)
+ [($its, add $bit), ($its, append $bit)] all mean: $its.bits, add $bit
assume (Buffer).is_a_buffer
$b = (a Buffer)
assume (type of $b) == "Buffer"
@@ -20,17 +25,15 @@ test:
assume "\$b" == ""
assume ($b, as text) == ""
$b = (a Buffer with {.bits = ["x"]})
- $b,
+ $b,
add "y"
append "z"
assume "\$b" == "xyz"
assume $b == (a Buffer with {.bits = ["x", "y", "z"]})
assume $b != (a Buffer with {.bits = []})
-
a (Comma Buffer) is a (Buffer):
($it, as text) means ($it.bits, joined with ",")
($its, number of commas) means ((#$its.bits) - 1)
-
$csv = (a Comma Buffer)
assume $csv.is_a_buffer
assume "\$csv" == ""
@@ -38,7 +41,6 @@ test:
$csv, add "y"
assume "\$csv" == "x,y"
assume ($csv, number of commas) == 1
-
a (Vec) is a thing with {.x, .y}:
($its, + $other) means (Vec {.x = ($its.x + $other.x), .y = ($its.y + $other.y)})
@@ -79,8 +81,7 @@ external:
fail "Cannot set \$key, it's not one of the allowed member fields."
set $class's metatable to {
- .__index = $parent
- .__tostring = ($class -> $class.__type)
+ .__index = $parent, .__tostring = ($class -> $class.__type)
.__call =
for ($class with $initial_values):
if ($initial_values == (nil)): return $class
@@ -107,7 +108,8 @@ external:
$class_id = ($classname.stub, as lua id)
$lua =
Lua ("
- \$class_id = a_1_class_named_2_with(\($parent as lua), \(quote $classname.stub), \($members as lua)\(
+ \$class_id = a_1_class_named_2_with(\($parent as lua), \(quote $classname.stub), \
+ ..\($members as lua)\(
(
Lua ("
, function(\$class_id)
@@ -120,20 +122,19 @@ external:
a_\$class_id = function(initial_values) return \$class_id(initial_values or {}) end
an_\$class_id, a_\($class_id)_with, an_\($class_id)_with = a_\$class_id, a_\$class_id, a_\$class_id
")
-
$lua, add free vars [$class_id, "a_\$class_id", "an_\$class_id"]
return $lua
-
+
[
a $classname is a thing with $members $class_body
an $classname is a thing with $members $class_body
a $classname is an thing with $members $class_body
an $classname is an thing with $members $class_body
] all parse as (a $classname is a (nil) with $members $class_body)
-
+
[a $classname is a thing $class_body, an $classname is a thing $class_body]
..all parse as (a $classname is a (nil) with (nil) $class_body)
-
+
[
a $classname is a $parent $class_body, an $classname is a $parent $class_body
a $classname is an $parent $class_body, an $classname is an $parent $class_body