if(false) is an error? Follow
It seems that in BaseLanguage, if (false) { ... } is an error because the body is an unreachable node. Is this intentional or a bug? It is incompatible with Java, so I would call it a bug.
Please sign in to leave a comment.
1. It is useful to have a way to suppress execution of code while continuing to validate the code e.g. for type errors. Does BaseLanguage have an equivalent? It looks like CommentedStatementBlock suppresses errors.
2. Perhaps the java importer should convert if (false) to a CommentedStatementBlock or equivalent?
Alan
2. Yes, this could be possible and makes a lot of sense.
I would still argue that if (false) is a useful programming tool and it is hard to believe that one would write if (false) by mistake, and isn’t the point of error messages to identify mistakes?
Personally I don't think that using if(false), while(false) etc is a good practice so this case should be considered separately. It's good to comment what you want to comment. In Java you don't use this technique everywhere due to tooling problems you've mentioned. But if we are arguing about tooling, it's not a problem in MPS at all to make comments work as we want.
Moreover, (again just IMO) making baseLanguage behaviour as close to Java behaviour in such cases is just not worth it; just makes not-so-experienced-in-java user wonder, why if (1!=1){} is a mistake and if (false) is not.
However, "if(false)" transformation in importer is a good idea since it makes less readable code more readable, not vice versa ;)