You can in a roundabout way. When you use a comptime function to define a struct type, the arguments given will end up in the type name:
const std = @import("std");
fn Useless(comptime arg: anytype) type {
return struct {
const stuff = arg;
};
}
pub fn main() void {
std.debug.print("{s}\n", .{@typeName(Useless(1234))});
std.debug.print("{s}\n", .{@typeName(Useless(.{ .pierogi = 12 }))});
}
fname.Useless(1234)
fname.Useless(.{ .pierogi = 12 })
If you pass a function as an argument, the function name shows up:
pub fn main() void {
const funs = comptime [_]FnType{
foo1,
foo2,
foo3,
};
inline for (funs) |fun| {
std.debug.print("{s}\n", .{@typeName(Useless(fun))});
}
}
fname.Useless((function 'foo1'))
fname.Useless((function 'foo2'))
fname.Useless((function 'foo3'))
Now it’s just a matter of plucking it out.