summaryrefslogtreecommitdiff
path: root/bos-object-id.sh
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2023-07-13 17:29:26 +0100
committerGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2023-07-13 17:29:26 +0100
commitc3141fc3b3c8d6fb7270a3a1cd15be4895ea052d (patch)
tree51e0ab1cca45f5d9491ab04b2a9ea80425a40474 /bos-object-id.sh
parentsome docs (diff)
downloadbash-object-system-c3141fc3b3c8d6fb7270a3a1cd15be4895ea052d.tar.gz
bash-object-system-c3141fc3b3c8d6fb7270a3a1cd15be4895ea052d.tar.bz2
bash-object-system-c3141fc3b3c8d6fb7270a3a1cd15be4895ea052d.zip
flailing about with MOPs
Diffstat (limited to 'bos-object-id.sh')
-rw-r--r--bos-object-id.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/bos-object-id.sh b/bos-object-id.sh
new file mode 100644
index 0000000..2026506
--- /dev/null
+++ b/bos-object-id.sh
@@ -0,0 +1,23 @@
+#!bash
+## object identity
+
+# objects are values, so they're stored in variables!
+#
+# the shape of that value is… a call to bos_invoke curry-ed on class and
+# id, so that `$my_obj the-method 1 2` is equivalent to `bos_invoke
+# TheClass $the_obj_id the-method 1 2`
+function bos-object-id/pack-self-into() {
+ local class="$1"
+ local self_id="$2"
+ local -n result="$3"
+ result="bos-dispatch/invoke $class $self_id"
+}
+
+# get class and object id from a $self string
+function bos-object/unpack-self-into() {
+ local self="$1"
+ local -n class="$2"
+ local -n id="$2"
+ local _
+ read -r _ class id <<<"$self"
+}