private
)Define a private function block
private
defines a function who’s scope is limited to that module or source file.
Privates cannot be called from one module to another (unless they’re wrapped around a global function
) and nor can they be called from the interactive command line. The purpose of a private
is to reduce repeated code inside a module or source file without cluttering up the global namespace.
private name { code-block }
# The following cannot be entered via the command line. You need to write
# it to a file and execute it from there.
private hw {
out "Hello, World!"
}
function tom {
hw
out "My name is Tom."
}
function dick {
hw
out "My name is Dick."
}
function harry {
hw
out "My name is Harry."
}
Private names can only include any characters apart from dollar ($
). This is to prevent functions from overwriting variables (see the order of preference below).
Because private functions are fixed to the source file that declares them, there isn’t much point in undefining them. Thus at this point in time, it is not possible to do so.
There is an order of precedence for which commands are looked up:
runmode
: this is executed before the rest of the script. It is invoked by the pre-compiler forking process and is required to sit at the top of any scripts.test
and pipe
functions also alter the behavior of the compiler and thus are executed ahead of any scripts.private
. Private’s cannot be global and are scoped only to the module or source that defined them. For example, You cannot call a private function directly from the interactive command line (however you can force an indirect call via fexec
).alias
. All aliases are global.function
. All functions are global.global
, set
or let
. Also environmental variables too, declared via export
.You can override this order of precedence via the fexec
and exec
builtins.
private
alias
): Create an alias for a commandexport
): Define an environmental variable and set it’s valueglobal
): Define a global variable and set it’s valuemethod
): Define a methods supported data-typesset
): Define a variable (typically local) and set it’s valueexec
): Runs an executablefexec
): Execute a command or function, bypassing the usual order of precedence.break
): Terminate execution of a block within your processes scopeg
): Glob pattern matching for file system objects (eg *.txt
)source
): Import Murex code from another file or code blockfunction
): Define a function blocklet
: Evaluate a mathematical function and assign to variable (deprecated)This document was generated from builtins/core/structs/function_doc.yaml.
This site's content is rebuilt automatically from murex's source code after each merge to the master
branch. Downloadable murex binaries are also built with the website.
Last built on Wed Sep 18 21:18:57 UTC 2024 against commit c037883c03788357164e9846c84d9f777251495d9452a8e.
Current version is 6.3.4225 (develop) which has been verified against tests cases.