Suppose I have a syntax tree node like this
pub const Spec = struct {
definitions: Array(Definition),
const Self = @This();
pub fn init(a: mem.Allocator) Self {
return .{
.definitions = Array(Definition).init(a),
};
}
pub fn deinit(self: *Self, a: mem.Allocator) void {
for (self.definitions.items) |*x|
x.deinit(a);
self.definitions.deinit();
}
};
The AST doesn’t live past the lifting into an intermediate representation.
Should I define a cleanup methods on each AST node or just rely on using an bump allocator?
I have cleanup methods all over the place but I’m wondering what the best style is.