Caller Source Location

Is it too much of an effort for the compiler to, besides having the builtin @src function, to, at comptime, have a @srcCaller function that would return the source location where the current function (where you are calling @srcCaller) was called from ?

I mean, you can already achieve this by adding a comptime src: std.builtin.SourceLocation parameter to all functions that need it.
If the compiler was to implement a comptime-known @srcCaller builtin it would behave exactly the same, effectively making every function that uses it generic. But it would be a lot less explicit since you couldn’t tell just from looking at its signature.

4 Likes
11 Likes