Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vec715 opened this issue May 5, 2025 · 0 comments
Open

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

vec715 opened this issue May 5, 2025 · 0 comments

Comments

@vec715
Copy link

vec715 commented May 5, 2025

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", "receiver@gmail.com", 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 = ["foo@gmail.com", "bar@gmail.com"];
       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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant