Use
If ( 2 + 2 = 4;...
instead of
If (
2 + 2 = 4;...
where the code should read as such
// Each result should be on its own line.
If ( 2 + 2 = 4 ;
True;
// else
False
)
Note the use of the dedicated comment line of // else. Either titlecase or lowercase can be used. It follows other language styles where else is part of the syntactic structure. Since the If() function does not read like code in other languages, we dedicate a line to clarify the false portion of the result. You can also use the block code format of /*else*/.
Finally, use blank lines and indentation in order to further clarify the start and end of embedded functions.
// Embedded functions use indenting so the outer function can still be identified.
If ( 2 + 2 = 4 ;
Let ( [
~A = 2;
~B = 2
];
~A + ~B
);
// else
False
)
This format
If ( Evaluate ( "Let ( [" & ~contents & "]; False )" ) = "?"
or ~empty // empty contents
or ~missingParams; // missing expected parameters
[...additional code...]
reads better than
If ( Evaluate( "Let ( [" & ~contents & "]; False )" ) = "?" or ~empty or ~missingParams;...
and also allows for inline comments
If ( Evaluate ( "Let ( [" & ~contents & "]; False )" ) = "?"
or ~empty // empty contents
or ~missingParams; // missing expected parameters
[...additional code...]
Case (
2 + 3 = 4 ;
False;
2 + 2 = 4 ;
True;
False // default result on its own line
)
Here's an example of a readable complex Case() statement.
Case (
Let ( [
~A = 2;
~B = 2
];
Let ( $value = ~A + ~B; $value = 4 )
);
// Result 1
Substitute ( "The result is %VALUE and it's %CONDITION";
[ "%VALUE" ; $value ];
[ "%CONDITION" ; If ( $value = 4 ; "GOOD" ; "BAD") ]
);
2 + 2 = 4;
// Result 2
True;
False // Default result on its own line.
)