This pull request changes how files are searched for in a #load directive.
Previously, there was a "search path" that the compiler would append the file's name onto the end of each entry in the search path, and see if that file exists. If so, that file would be used. This was repeated for every entry in the list. By default the only two folders in the search path were the current directory and the ONYX_PATH.
Now, #load directives must either be relative to the current file (start with ./), or specify a mapped folder name to search from. This way, the programmer is aware of exactly where the file comes from.
In the code, it looks like this:
// Load the `onyx/compiler_extension.onyx` file from the `core` mapped directory.
#load "core:onyx/compiler_extension"
// ...
By default, there is now only one mapped directory called core, which points to ONYX_PATH/core. You can add mapped directories using the --map-dir CLI argument:
onyx run --map-dir libs:/path/to/libraries main.onyx
This pull request changes how files are searched for in a
#load
directive.Previously, there was a "search path" that the compiler would append the file's name onto the end of each entry in the search path, and see if that file exists. If so, that file would be used. This was repeated for every entry in the list. By default the only two folders in the search path were the current directory and the
ONYX_PATH
.Now,
#load
directives must either be relative to the current file (start with./
), or specify a mapped folder name to search from. This way, the programmer is aware of exactly where the file comes from.In the code, it looks like this:
By default, there is now only one mapped directory called
core
, which points toONYX_PATH/core
. You can add mapped directories using the--map-dir
CLI argument: