Hi, Have created an expression rule "increment" with one ru

Certified Senior Developer
Hi,

Have created an expression rule "increment" with one rule input "x", has the following definition :

with(
ri!x:ri!x + 1,
ri!x
)

I call this rule from another expression rule ::

with(
local!a:rule!increment(x:ri!y),
local!a
)

returns 11 if value of ri!y is 10, works fine.

But if I use the following code:

with(
local!a:rule!increment(x:ri!y),
ri!y
)

returns 10 if value of ri!y is 10.

I have two queries here :

1. Are rule inputs to expression rules Passed By Reference or Value ?
2. How can I design a rule which can return multiple values ?



OriginalPostID-167802

OriginalPostID-167802

  Discussion posts and replies are publicly visible

Parents
  • @vikrantb, this is a tricky one, but also a common mistake trying to update rule inputs using with() or load() function. By defining this:

    with(
    ri!x:ri!x + 1,
    ri!x
    )

    You actually created a local variable called ri!x, with value of rule input x + 1. Then you returned value of that local variable. No update made to the rule input.

    We've seen this "pass by reference" magic works in SAIL expressions, but note that all the changes made to rule inputs are done in "Saving Phase" of SAIL evaluation. You can update rule inputs within saveInto of SAIL components.
Reply
  • @vikrantb, this is a tricky one, but also a common mistake trying to update rule inputs using with() or load() function. By defining this:

    with(
    ri!x:ri!x + 1,
    ri!x
    )

    You actually created a local variable called ri!x, with value of rule input x + 1. Then you returned value of that local variable. No update made to the rule input.

    We've seen this "pass by reference" magic works in SAIL expressions, but note that all the changes made to rule inputs are done in "Saving Phase" of SAIL evaluation. You can update rule inputs within saveInto of SAIL components.
Children
No Data