Robin, Seth, and I were talking about doing the following changes/additions
to the script loading functionality in case anyone has input:
1) When an @load or command line argument relies on BROPATH to search for
the script/package, directory separator characters (i.e. '/') must be
replaced with dots ('.'). e.g. "@load frameworks.software". ".bro"
file extensions are still optional.
This makes loading packaged scripts look more similar to other languages
and better supports the new @prefixes implementation described below.
2) Allow @load to recognize absolute paths or paths relative to the currently-
e.g. if foo.bro and bar.bro live in the same directory, bar.bro can do
"@load ./foo". ".bro" file extension is still optional.
When a script is loaded relatively, we're still going to have to be able
to track where it is within BROPATH (if it is at all) in order for change
(4) described below to work.
This doesn't really conflict with rule (1) about replacing path separator
characters with dots when naming scripts-to-load since in this case we're
not relying on BROPATH, but I wonder if that's not really clear since @load
is used in both cases, with (2) being implied by arguments that start with
'.' or '/'. Maybe we should use a new directive other than @load for this
3) A new "@add x when y ..." directive that's an alternative to @load, and
can be used to conditionally load script named 'x' only when the script
named 'y' has already been loaded. The evaluation of that condition is
postponed until after all scripts specified via @load or as command line
arguments have been loaded. 'x' and 'y' can be named according to either
(1) or (2) above.
4) The way the @prefixes directive works is going to change. It currently
augments future @loads by additionally checking for a prefixed version of
the argument, meaning @prefixes has to be specified very early on for it to
work right. The new implementation of @prefixes will mean: after all
scripts have been loaded, for each script and for each prefix, search
BROPATH for a prefixed version of the script in the "dot-syntax" specified
by (1) and load it if it exists (if the script is a __load__.bro the
__load__ part is ignored in the canonicalized version of the name such that
it appears as if it's a "package" once again).
e.g. doing "@load frameworks.software" and a "@prefixes local" means a file
in BROPATH named "local.frameworks.software.bro" in BROPATH, will be loaded
at the end of the script loading process if it exists. ".bro" extension