4 ms·
I can't say for sure, but I suspect it was a reaction to ALGOL-68. Creators of later Algolish languages usually made a point of rejecting features of Algol-68 t
by tangus 5y ago
I can't say for sure, but I suspect it was a reaction to ALGOL-68. Creators of later Algolish languages usually made a point of rejecting features of Algol-68 they saw as prone to abuse.
And the block expressions in Algol-68 were certainly used and abused. Basically, the type and value of a block (BEGIN ... END or ( ... )) are those of its last expression, so you can put them anywhere. For example, Algol-68 has the looping construct WHILE <condition> DO <body> OD, but not C's `do <body> while (<condition>)`. So what do you do if you want to have the test at the end of the loop body? Simply
WHILE (
<body>;
<condition>
)
DO SKIP OD
I guess you'd get used to those idioms eventually, or some coding conventions would have arisen if the language had been successful. But I can understand language creators looking at that and seeing how getting rid of it simplifies not only their compilers but also the programs written in their languages.
- Wildgoose 5y agoWhat is wrong with simply: test := True; WHILE test DO <body>; test = <condition> OD
- chalst 5y agoThat introduces a variable that has to be initialised outside the control block. It's not terrible as hacks go, but I guess the readability cost of the additional variable is higher than having the body in the condition.
- tangus 5y agoNothing is wrong with it, but your suggestion comes 40 years too late. The popular idiom was the one I mentioned.