From ca62aa365faee27895f8cb1eccddd7af8a7d15c9 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 17 Mar 2025 22:18:21 -0400 Subject: Switch types to use wordier syntax `[T]` -> `List(T)` etc --- stdlib/arrays.c | 2 +- stdlib/arrays.h | 4 ++-- stdlib/tables.c | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'stdlib') diff --git a/stdlib/arrays.c b/stdlib/arrays.c index 41d46741..1e1ce5f0 100644 --- a/stdlib/arrays.c +++ b/stdlib/arrays.c @@ -555,7 +555,7 @@ public Text_t Array$as_text(const void *obj, bool colorize, const TypeInfo_t *ty { Array_t *arr = (Array_t*)obj; if (!arr) - return Text$concat(Text("["), generic_as_text(NULL, false, type->ArrayInfo.item), Text("]")); + return Text$concat(Text("List("), generic_as_text(NULL, false, type->ArrayInfo.item), Text(")")); const TypeInfo_t *item_type = type->ArrayInfo.item; Text_t text = Text("["); diff --git a/stdlib/arrays.h b/stdlib/arrays.h index 332a1db0..6b88b1ee 100644 --- a/stdlib/arrays.h +++ b/stdlib/arrays.h @@ -36,7 +36,7 @@ #define Array_set(item_type, arr, index, value, start, end) \ Array_lvalue(item_type, arr_expr, index, start, end) = value #define is_atomic(x) _Generic(x, bool: true, int8_t: true, int16_t: true, int32_t: true, int64_t: true, float: true, double: true, default: false) -#define TypedArray(t, ...) ({ t items[] = {__VA_ARGS__}; \ +#define TypedList(t, ...) ({ t items[] = {__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)), \ @@ -48,7 +48,7 @@ .data=memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \ .atomic=0, \ .data_refcount=0}; }) -#define Array(x, ...) ({ __typeof(x) items[] = {x, __VA_ARGS__}; \ +#define List(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(is_atomic(x) ? GC_MALLOC_ATOMIC(sizeof(items)) : GC_MALLOC(sizeof(items)), items, sizeof(items)), \ diff --git a/stdlib/tables.c b/stdlib/tables.c index 97419327..73a3af19 100644 --- a/stdlib/tables.c +++ b/stdlib/tables.c @@ -582,16 +582,16 @@ public Text_t Table$as_text(const void *obj, bool colorize, const TypeInfo_t *ty if (!t) { if (table.value != &Void$info) return Text$concat( - Text("{"), + Text("Table("), generic_as_text(NULL, false, table.key), - Text(","), + Text(", "), generic_as_text(NULL, false, table.value), - Text("}")); + Text(")")); else return Text$concat( - Text("{"), + Text("Set("), generic_as_text(NULL, false, table.key), - Text("}")); + Text(")")); } int64_t val_off = (int64_t)value_offset(type); @@ -606,7 +606,7 @@ public Text_t Table$as_text(const void *obj, bool colorize, const TypeInfo_t *ty } if (t->fallback) { - text = Text$concat(text, Text("; fallback="), Table$as_text(t->fallback, colorize, type)); + text = Text$concat(text, colorize ? Text("; \033[33mfallback\033[m=") : Text("; fallback="), Table$as_text(t->fallback, colorize, type)); } text = Text$concat(text, Text("}")); -- cgit v1.2.3