#comptime function that allocs runtime heap pointer (?)

1 messages · Page 1 of 1 (latest)

grizzled rivet
#

sorry, i'm going to avoid your actual question and ask: why do this at all?

it seems like you're replacing a few lines + an init function with a bunch of metaprogramming that ultimately amounts to roughly the same thing

e.g. you could just be doing (if you want to keep the ExampleObject heap allocated):

var example = try alloc.create(ExampleObject);
example.* = ExampleObject.init(alloc);
defer {
    ExampleObject.deinit();
    alloc.destroy(example);
}
#

i feel like zig kinda leans into the philosophy of "just write them out by hand"

#

that'd be up to your init function implementation