Journal of my investigation into the development of a new programming language
Conditionals: Question/Answer/Action
Here is what I want to use for conditionals:
[is] a > 5?
if so: print "big"
if not: print "small"
[is] a > 5?
yes:
print "big"
subtract 3 from a
no:
print "small"
add 2 to a
[what is] a?
it > 5: print "big"
it > 3: print "medium"
otherwise: print "small"
[what is] a?
> 5:
print "big"
subtract 3 from a
> 3:
print "medium"
else:
print "small"
add 2 to a
It treats IF and CASE consistently.
It splits out the two roles of the conventional IF clause - generally, IF represents both question and (answer = true), while ELSE represents only (answer = false). Which leads to problematic issues like
ELSE IF.
The only objection I have to this is that simple multiline IF's require double-indentation. This implies that the code is more complex than it really is. I want apparent code complexity to correspond closely to actual code complexity, and I want to reduce indentation levels generally, with things like implicit loops and trailing IF and UNLESS clauses. But at the moment, at least, I'm willing to accept the extra indentation for the sake of consistency.
A few little notes: "if" and "it" can be left off the answer clauses; "if so" is synonymous with "if it is" and "yes"; "if not" is synonymous with "no" (in the answer clause context); questions load the special "it" variable.