package
package keyword declares a package.
Purpose
This keyword is used to declare rule packages that you can use to better manage IRL artifacts such as variables, functions, rules, and tasks.
Context
At the top level of rulesets
Syntax
package packageName {variables, functions, rules, tasks}
Description
Rule packages are held by the
ruleset. A ruleset contains at least one package, the default package.
The default package name is the empty string. IRL artifacts defined
outside a package definition are considered to be part of the default
package. An IRL artifact has a short name, which is the name used
for its definition, and a fully qualified name, which is its short
name prefixed with its package name. You can use IRL artifacts defined
in a package A in another package B by either referencing the artifacts
by their fully qualified name or if their package is imported into
the package B, by using the use keyword. You cannot
import the default package, but you can import the artifacts of the
default package.
Example
function void displayPrice(double price)
{
...
}
package pricing
{
variables {
Customer customer;
}
rule isEligible
{
when {
...
}
then {
...
}
}
}
package europe.pricing
{
use pricing.*;
use displayPrice(double);
ruletask main
{
body {
isEligible
}
finalaction {
displayPrice(3.2d);
}
}
}
rule FlightDisplayExpired {
};This example defines two packages, pricing and europe.pricing.
The displayPrice function belongs to the default
package. The europe.pricing package uses the pricing package
and the displayPrice function.