I propose adding an if construct, restricted by the parser to equality tests:
foo := if A == B { THEN } else { ELSE }
A, B, THEN, and ELSE are all arbitrary expressions. If A equal to B then it will evaluate as THEN, otherwise it will evaluate as ELSE.
The reason I propose adding if, restricted to equality testing, instead of a more general if, is because if, in some future in which Just get's a type system, I would like the condition, A == B above, of if to be a bool. By restricting if to equality testing, a future enhancement which adds boolean and relaxes `if's condition to be any expression would not be a breaking change.
I added the good first issue tag to this. It's tough, but I think doable for someone that's interested in learning how the lexer and parser work. The only complication I see is making sure that if isn't always parsed as a keyword, so that having a recipe named if doesn't become an error.
(See prior discussion in #262 and #674.)
I propose adding an
ifconstruct, restricted by the parser to equality tests:A,B,THEN, andELSEare all arbitrary expressions. IfAequal toBthen it will evaluate asTHEN, otherwise it will evaluate asELSE.The reason I propose adding
if, restricted to equality testing, instead of a more generalif, is because if, in some future in which Just get's a type system, I would like the condition,A == Babove, ofifto be a bool. By restrictingifto equality testing, a future enhancement which adds boolean and relaxes `if's condition to be any expression would not be a breaking change.I added the
good first issuetag to this. It's tough, but I think doable for someone that's interested in learning how the lexer and parser work. The only complication I see is making sure thatifisn't always parsed as a keyword, so that having a recipe namedifdoesn't become an error.(See prior discussion in #262 and #674.)