Closed jeandrek closed 7 years ago
Looks like the if
outputs one too many spaces, still.
if (n == 0l)
^^
Oh, I didn't notice that.
Note: with this then blocks in if/while/for statements aren't special cases, so
to main do
if 1 = 1 then do
display(1) display(2)
end
end
compiles to
int main() {
{
if (1l == 1l)
{
display(1l);
display(2l);
}
}
return 0l;
}
This makes sense to me, but many programmers hate this style of indentation. Should it change?
..many C programmers hate this style..
Yeah, probably best to use 1TBS, if possible... the best result would be not generating do .. end
braces when they aren't needed:
int main()
{
if (1l == 1l) {
display(1l);
display(2l);
}
return 0l;
}
Okay, so have a procedure called compile_statement_wo_extra_braces
or something and have the code generators for if
, forever
, while
and for each
output braces call it instead of compile_statement
?
Now the factorial example compiles to