I am fully aware of the history, source, and how to use the Rules DSL. Way back in OH 1.x I wrote the main guide for how to properly use lambdas in Rules DSL. Reusable Functions: A simple lambda example with copious notes (this eventually was added to the wiki but the wiki is long gone).
A lambda is not the same as a function. For one there’s a limit of only 7 arguments. For two, they do not have a call stack so no recursion and if two rules call it at the same time you are in trouble.
And you cannot pass arguments to this script.
That’s a pretty extreme work around for a such a fundamental limitation of the language. Furthermore, there will be no synchronization. And because lambdas become actual Objects in Xtend instead of proper functions where each call to it gets its own stack, if two rules call the same lambda at the same time they will interfere with each other.
For example, rule one calls the lambda with argument a=foo. it starts running. Rule two calls the lambda with argument a=bar. From now on, both rule one’s call and rule two’s call to the lambda will see argument a=bar.