Require
This section of the manual describes the Require
module.
ReachabilityBase.Require
— ModuleRequire
This module provides convenience functionality to be used in combination with the Requires.jl
package.
ReachabilityBase.Require.require
— Functionrequire(mod, packages; [fun_name]::String="", [explanation]::String="")
Check for one or more optional packages and print an error message if any of them is not loaded.
Input
mod
– module where the package should be loaded; use@__MODULE__
packages
– symbol or list of symbols (the package name(s))fun_name
– (optional; default:""
) name of the function that requires the packageexplanation
– (optional; default:""
) additional explanation in the error messagerequire_all
– (optional; default:true
) flag to require allpackages
Output
If all packages are loaded, this function has no effect. Otherwise, it prints an error message.
Notes
The argument mod
should typically be @__MODULE__
, but since this is a macro, it has to be inserted by the caller.
The argument require_all
can be set to false
to require only one of the given packages. This is useful if multiple packages provide a functionality and any of them is fine.
This function uses @assert
and hence loses its ability to print an error message if assertions are deactivated (see the Assertions
module).
See also the @required
macro for a more concise syntax.
ReachabilityBase.Require.@required
— Macro@required(package)
Check for an optional package and print an error message if any of them is not loaded.
Input
package
– package name
Output
If the package is loaded, this macro has no effect. Otherwise, it prints an error message.
This macro uses @assert
and hence loses its ability to print an error message if assertions are deactivated (see the Assertions
module).
See also the require
function for a more customizable version.