Re:A Regular Expression Matcher (2007)
by adrianratnapala on Monday August 01, 2016 @01:00AM
(#12200290)
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.
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.