JanetDocsSourcePlaygroundI'm feeling luckyCommunityGitHub sign in

*current-file*

core-api


    keyword
    boot.janet on line 1343, column 1

    Bound to the name of the currently compiling file.


1 exampleSign in to add an example
Loading...
# From the REPL, always nil
repl> (dyn *current-file*)
nil

# As an expression to the CLI, always nil
$ janet -e '(pp (dyn *current-file*))'
nil

# Given the file /tmp/janet/test.janet with the following contents:
(pp (dyn *current-file*))

# Note how the value reflects the given file path
~ $ janet /tmp/janet/test.janet
"/tmp/janet/test.janet"

/tmp/janet $ janet ./test.janet
"./test.janet"

/tmp/janet $ janet test.janet
"test.janet"

/tmp/janet $ janet ../janet/test.janet
"../janet/test.janet"

# The following are equivalent - the first is preferred.
# The key insight is that dynamic bindings are just keyword/value
# pairs in the current fiber's environment table.
(dyn *current-file*)
(dyn :current-file)
((curenv) *current-file*)
((curenv) :current-file)
quexxonPlayground