The usual reason is for derivers, right? Eg derive a JSON Schema from an OCaml record type. Kinda simple when you have ‘comptime’ and iterate over the record fields, writing out a JSON Schema for each field.
Don’t you need to switch over type information to do a JSON schema deriver … which comptime, std.meta.fieldNames and @field alone do not provide? For example, how would you know that a field a is a struct rather than an integer, and print the JSON accordingly?
In C++ templates you could use SFINAE for type switching. What is the mechanism for Zig comptime, and more importantly, what would be the mechanism for OCaml? In particular for OCaml, you would need some generic type representation from the compiler, available at compile time, on top of compile time evaluation, no?
I guess you need something like ‘give me the reified type of this field’? Eg FieldType. And then you can switch on this type value.