I think the only way you could have knowledge about the caller scope is by using a macro.
Quoting the Julia documentation:
In addition to the given argument list, every macro is passed extra arguments named
__source__and__module__.The argument
__source__provides information (in the form of aLineNumberNodeobject) about the parser location of the@sign from the macro invocation. This allows macros to include better error diagnostic information, and is commonly used by logging, string-parser macros, and docs, for example, as well as to implement the@__LINE__,@__FILE__, and@__DIR__macros.The location information can be accessed by referencing
__source__.lineand__source__.file
So you could do something like this:
macro export_to_jupyter(...)
notebook_name = __source__.file
return quote
... # code using $notebook_name
end
end