Skip to content

Why there is no way to add variable declaration inside rules? #480

@vec715

Description

@vec715

Writing rules always limited to working only with the provided set of structures and their fields. When some function should accept some arguments we need to define them directly e.g.:

rule ... {
    when
        ...
    then
       fn.SendAlert("title", "body", "[email protected]", fn.CalculateSomethingX(), fn.CalculateSomethingY());
}

But it would be much much easier to read & maintain the rules if we can have a variable declaration:

rule ... {
    when
        ...
    then
       var x = fn.CalculateSomethingX(...);
       var y = fn.CalculateSomthingY(...);
       var receivers = ["[email protected]", "[email protected]"];
       var body = "very long long body here";
       fn.SendAlert("title", body, receivers, x, y);
}

Why this feature is unavailable? I wonder what type of limitations we have so there is no such a way to declare variables inside the rule?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions