From ed7da0d9e31e8dd6847e2e603f0d1943330cf4d0 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 13 Mar 2026 14:07:29 +0200 Subject: add initial reference invalidation + Makes vec example actually memory safe, which is cool + Specify owner > sub relationships with ">" in closure parameter lists, uses the same group idea as closure calls + Relies on users implementing functions in a consistent manner, since you can kind of do whatever with pointers. Presumably there would be a stdlib of vec/map/set etc. which applications could then use and by proxy be memory safe. Although some more checks wouldn't hurt, I suppose? + Not sure I like having reference invalidation be 'just a move', seems to work alright but the semantics of it are a bit muddy. --- include/fwd/ast.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/fwd/ast.h b/include/fwd/ast.h index f550647..4359525 100644 --- a/include/fwd/ast.h +++ b/include/fwd/ast.h @@ -103,6 +103,15 @@ struct type { /* next */ struct type *n; + /* used in parameter lists; this param owns the next one + * + * Is a pointer necessary here? A bool could work as well, as long as we're + * just doing 'this owns the next element in this list', but if we + * eventually support more complex relationships, like 'this owns these + * next params and one of the next params owns at least one more' or + * something along those lines, but that's an unsure TODO) */ + struct type *or; + /* opt group */ long group; @@ -727,5 +736,6 @@ static inline struct type *callable_types(struct type *t) } void opt_group(struct ast *a, struct ast *b); +void own_type_group(struct type *owner, struct type *sub); #endif /* AST_H */ -- cgit v1.2.3