-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to get file/line of a function's caller? cf in D: void fun(string file=__FILE__) #7406
Comments
void fun(string file=__FILE__)
?
check |
sorry could you please post a working test case?
|
type
FileInfo = tuple[filename: string, line: int]
proc fooImpl(callerInfo: FileInfo) =
echo callerInfo.filename, ":", callerInfo.line
template foo(): untyped =
fooImpl(instantiationInfo())
foo()
foo()
Since my particular file is called "test.nim", the output is the following:
|
thanks, so it confirms what I was afraid of which is that this isnt' possible without introducing template bloat. Could nim implement this feature just like it's done in D? in D, optional arguments (eg otherwise, what are (objectively) the downsides of using |
There is no template bloat. |
how to get file/line of a function's caller?
in D this works:
in D we can get the file/line of a function caller using
__FILE__, __LINE__ (__MODULE__, etc)
how would we do that in nim proc's ?
NOTE: this also doesn't work:
NOTE: looking for a solution that works with
proc
(eg, no template bloat)The text was updated successfully, but these errors were encountered: