Comment by johndoe0815
4 years ago
Steve Bourne used a set of macros to enable ALGOL-like programming in C and used it to implement his Unix shell - https://research.swtch.com/shmacro
4 years ago
Steve Bourne used a set of macros to enable ALGOL-like programming in C and used it to implement his Unix shell - https://research.swtch.com/shmacro
This is obviously terrible, but my favorite part of this whole thing is the fact that he included the parentheses in the IF/THEN macros, so you didn't have to do it for the condition in the if statement. So, like, this line doesn't need parentheses around the condition:
All modern languages that try and do a refresh on the C style (Rust and Swift notably) do this, it's clearly the right idea. They should just update the C and C++ syntax to make those parentheses optional at this point.
(PS. some people would also recoil at the assignment-as-expression used in that line, but that's just good clean fun!)
They already make them optional for single nested statements, which causes a gigantic mess when you extend code and forget to add them.
is interpreted as
Some compilers are nice enough to throw around misleading indentation warnings, but without an explicit block termination like FI this just causes issues all over the place.
he meant making the (a) part optional to make "if a" instead. parenthesis are (), {} are braces :)
14 replies →
ha, I was googling FORTRAN C macros and went nowhere, that was the page I was looking for :)