grammarware / software-evolution

Software Evolution
MIT License
1 stars 0 forks source link

If statement condition #5

Open andreioff opened 6 months ago

andreioff commented 6 months ago

What exactly should be covered in the BooleanExpression of an if statement in BabyCobol? This COBOL reference from IBM talks about quite a few options for the conditional expressions of an if statement. Is it sufficient if we support comparisons of arithmetic operations (both on atomic values and variables) and strings?

Furthermore, on this page of the same COBOL reference, there are specific keywords used in the condition of an if statement (e.g. AND, OR and NOT). Does it matter if we use such keywords, or can we just use the normal mathematical signs (i.e. <, >, =, etc.)?

grammarware commented 6 months ago

Many of those do not make sense in BabyCobol since it lacks the VALUES clause in DATA DIVISION definitions and does not even support comparison refusals like ANY.

I'd say you can already demonstrate what your framework can do, with a handful of comparison binary operators that get you from decimals to Booleans (e.g., <, >, = and <>), and another handful of combinatory binary operators that get two Boolean and give you another Boolean (e.g., AND and OR). NOT is only interesting if you are implementing both variants of it: (1) negating a Boolean expression — e.g., NOT (X > 2); and (2) negating a binary operator — e.g., X NOT > 2. Adding more binary operators is straightforward but does consume a lot of time, so I'd suggest to leave them.

The same with arithmetics: getting +, -, * and / will already make for a nice EVALUATE, and you will be able to demonstrate the strength of your type checker that might, for example, accept 2+2 as well as 2-2, but will accept "two"+"two" while refusing "two"-"two".