3 ms·
I use unbraced blocks as an unwise habit brought over from Pascal, which I learned before C. I think of these things not as "blocks" but as "statements" -- tho
by adrianratnapala 10y ago
I use unbraced blocks as an unwise habit brought over from Pascal, which I learned before C.
I think of these things not as "blocks" but as "statements" -- those can be sandwiched between begin/end or else be one-liners. Pretending that one-liners aren't statements doesn't make any sense at all.
The rules of C are the same -- except it doesn't work as well in practice. Because
(1) explicit `{...}` in a one-liner is far less painful than explicit `begin...end`.
(2) errors caused by a missing `{`, `}` are harder to spot than errors caused by missing `begin`, `end`.
That said, the best syntax I know of for this is indentation based -- then the whole issue just goes away.