Open amano-kenji opened 7 months ago
Although there is mention of init.janet
at https://janet-lang.org/docs/modules.html, reading the text there didn't lead me to deduce the current behavior.
For reference, I think a relevant line of source in boot.janet
is this one:
(module/add-paths "/init.janet" :source)
May be this section of the website docs would be a good place to mention behavior with respect to init.janet
.
If something is going to be added to the website docs about /init.janet
, may be it makes sense to mention the other items that are searched for (and the order as well).
IIUC, for (import foo)
, at least four things might be looked for in the following order:
foo.jimage
foo.janet
foo/init.janet
foo.<native-extension>
(Here, <native-extension>
is likely to be .so
on a Linux machine or .dll
on Windows.)
I think the search is done in the above order and the first match "wins". That is, once a match is found, the search ends and an attempt is made to "import" the matched item.
For reference, here are some relevant-looking lines from boot.janet
.
In the above error, I saw that
(import ./ok)
tries to loadok/init.janet
after trying to loadok.janet
.This behavior is not documented on https://janet-lang.org/docs/modules.html.
This is significant for module organization.