aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-21 22:55:03 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-21 22:55:03 -0400
commit0d36812c6af951a41caac77d5f312949f3bc521f (patch)
treeae0f545805c524ffa467b925687bf70e88e2bc58 /src/stdlib
parentfa7a0ddc0963deb387f0cae7bb22ca968ee9146f (diff)
Deprecate binary ops (other than ++) for tables. Instead use proper
methods: t.with(other), t.without(other), t.intersection(other), t.difference(other)
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/tables.c16
-rw-r--r--src/stdlib/tables.h8
2 files changed, 12 insertions, 12 deletions
diff --git a/src/stdlib/tables.c b/src/stdlib/tables.c
index bda55375..6698dea3 100644
--- a/src/stdlib/tables.c
+++ b/src/stdlib/tables.c
@@ -577,9 +577,9 @@ Table_t Table$from_entries(List_t entries, const TypeInfo_t *type) {
return t;
}
-// And is "set intersection" in formal terms
+// "set intersection" in formal terms
public
-Table_t Table$and(Table_t a, Table_t b, const TypeInfo_t *type) {
+Table_t Table$intersection(Table_t a, Table_t b, const TypeInfo_t *type) {
// Return a table such that t[k]==a[k] for all k such that a.has(k), b.has(k), and a[k]==b[k]
Table_t result = {};
const size_t offset = value_offset(type);
@@ -595,9 +595,9 @@ Table_t Table$and(Table_t a, Table_t b, const TypeInfo_t *type) {
return result;
}
-// Or is "set union" in formal terms
+// "set union" in formal terms
public
-Table_t Table$or(Table_t a, Table_t b, const TypeInfo_t *type) {
+Table_t Table$with(Table_t a, Table_t b, const TypeInfo_t *type) {
// return a table such that t[k]==b[k] for all k such that b.has(k), and t[k]==a[k] for all k such that a.has(k) and
// not b.has(k)
Table_t result = {};
@@ -617,9 +617,9 @@ Table_t Table$or(Table_t a, Table_t b, const TypeInfo_t *type) {
return result;
}
-// Xor is "disjunctive union" or "symmetric difference" in formal terms
+// "disjunctive union" or "symmetric difference" in formal terms
public
-Table_t Table$xor(Table_t a, Table_t b, const TypeInfo_t *type) {
+Table_t Table$difference(Table_t a, Table_t b, const TypeInfo_t *type) {
// return a table with elements in `a` or `b`, but not both
Table_t result = {};
const size_t offset = value_offset(type);
@@ -638,9 +638,9 @@ Table_t Table$xor(Table_t a, Table_t b, const TypeInfo_t *type) {
return result;
}
-// Minus is "set difference" in formal terms
+// "without" is "set difference" in formal terms
public
-Table_t Table$minus(Table_t a, Table_t b, const TypeInfo_t *type) {
+Table_t Table$without(Table_t a, Table_t b, const TypeInfo_t *type) {
// Return a table such that t[k]==a[k] for all k such that not b.has(k) or b[k] != a[k]
Table_t result = {};
const size_t offset = value_offset(type);
diff --git a/src/stdlib/tables.h b/src/stdlib/tables.h
index 4364530a..f4870f80 100644
--- a/src/stdlib/tables.h
+++ b/src/stdlib/tables.h
@@ -91,10 +91,10 @@ void Table$remove(Table_t *t, const void *key, const TypeInfo_t *type);
Table$remove(t, &k, type); \
})
-Table_t Table$and(Table_t a, Table_t b, const TypeInfo_t *type);
-Table_t Table$or(Table_t a, Table_t b, const TypeInfo_t *type);
-Table_t Table$minus(Table_t a, Table_t b, const TypeInfo_t *type);
-Table_t Table$xor(Table_t a, Table_t b, const TypeInfo_t *type);
+Table_t Table$intersection(Table_t a, Table_t b, const TypeInfo_t *type);
+Table_t Table$with(Table_t a, Table_t b, const TypeInfo_t *type);
+Table_t Table$without(Table_t a, Table_t b, const TypeInfo_t *type);
+Table_t Table$difference(Table_t a, Table_t b, const TypeInfo_t *type);
Table_t Table$with_fallback(Table_t t, OptionalTable_t fallback);
void Table$clear(Table_t *t);