aboutsummaryrefslogtreecommitdiff
path: root/nextlang.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-17 23:43:55 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-17 23:43:55 -0500
commitfbf39cd7e907f32824cc0bb763f38851b1726cfd (patch)
treef9ef822ad1967a9d371936586ac13c890cb2cb50 /nextlang.h
parent2345c8c5c93b8c18866f09310f8a9d9e35962823 (diff)
Various fixes, including for Null values
Diffstat (limited to 'nextlang.h')
-rw-r--r--nextlang.h9
1 files changed, 0 insertions, 9 deletions
diff --git a/nextlang.h b/nextlang.h
index a7e45935..d81fe2e2 100644
--- a/nextlang.h
+++ b/nextlang.h
@@ -40,15 +40,6 @@ CORD as_cord(void *x, bool use_color, const char *fmt, ...);
default: "???")
#define $heap(x) (__typeof(x)*)memcpy(GC_MALLOC(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x))
#define $stack(x) (__typeof(x)*)((__typeof(x)[1]){x})
-#define $length(x) _Generic(x, default: (x).length)
-// Convert negative indices to back-indexed without branching: index0 = index + (index < 0)*(len+1)) - 1
-#define $index(x, i) _Generic(x, array_t: ({ __typeof(x) $obj; int64_t $offset = i; $offset += ($offset < 0) * ($obj.length + 1) - 1; assert($offset >= 0 && offset < $obj.length); $obj.data + $obj.stride * $offset;}))
-#define $safe_index(x, i) _Generic(x, array_t: ({ __typeof(x) $obj; int64_t $offset = i - 1; $obj.data + $obj.stride * $offset;}))
-#define $array(x, ...) ({ __typeof(x) $items[] = {x, __VA_ARGS__}; \
- (array_t){.length=sizeof($items)/sizeof($items[0]), \
- .stride=(int64_t)&$items[1] - (int64_t)&$items[0], \
- .data=memcpy(GC_MALLOC(sizeof($items)), $items, sizeof($items)), \
- .copy_on_write=1}; })
#define not(x) _Generic(x, bool: (bool)!(x), default: ~(x))
#define and(x, y) _Generic(x, bool: (bool)((x) && (y)), default: ((x) & (y)))