-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
var in lambda #4493
Comments
If you delete which variable? What specifically is the "corresponding message" Please provide more details and logs. In Rules DSL, variables defined in the global context cannot see each other. So Are you reporting a change from this expected behavior or is it working as expected? |
|
The Validation warning is just that, a warning. It's just letting you know that you may not have wanted to create an expression like that as a constant in that context. But it's using it anyway since it's syntactically valid. And there isn't an error when the lambda runs because lambdas in general can see constants without problems. Though because the constant is declared globally I'm a little suprised it worked, but I guess it did (I assume you saw the The error in the second case comes from what I explained above. Globally defined lambdas cannot see any vars defined outside of it. So when the lambda is called it doesn't know anything about the variable It's weirdness like this (and this is a minor one) that cause me to recommend against new development of rules using Rules DSL. Any of the other languages work in a more consistent way and are now just as easy to work with. If you need to change a global variable in a globally defined lambda, use the But as far as I can tell, this is working as it always has and it's working as Xtend has designed. |
It is and was already clear to me that lambdas cannot/should not access global variables. This isn't about me having a problem with it either. I only find the corresponding reactions to this problem irritating, even for others. With global val a "Validation issues" is output. The condition if(wIL) in Lambda is not satisfied. With global var nothing happens. In my opinion, correct information only comes if var is not defined. All of this should just be a help to make it even better for beginners. If this is not desired, we can also save ourselves the effort in the future. |
I'm not saying this isn't desired. We have no control over it. All of that stuff is AFAIK implemented upstream, not by OH. And I'm strongly of the opinion that beginners should not be using Rules DSL any more anyway. This is only one tiny problem with Rules DSL that will mess users up which OH has no control over. For example:
The advantages Rules DSL once had are no longer advantages over the other options and the disadvantages are severe. New users should not be using Rules DSL and existing users should not be using Rules DSL for new rules development. That's just my opinion but it's an informed one. Rules DSL was great through about OH 3.2 but it has since been surpassed by Blockly, jRuby, and JS Scripting in completeness, ease of use, and consistency. |
oH 4.3.0.M5
The rule is executed without an error message even though the variable is not defined within the lambda, but the global variable is correctly not recognized within the lambda either. If I delete the variable I get a corresponding message during execution.
The text was updated successfully, but these errors were encountered: