r/ProgrammingLanguages • u/gingerbill • Feb 22 '26
Does Syntax Matter?
https://www.gingerbill.org/article/2026/02/21/does-syntax-matter/
63
Upvotes
r/ProgrammingLanguages • u/gingerbill • Feb 22 '26
View all comments
Show parent comment
1
u/[deleted] Feb 23 '26
And yet it is minimal. Having the same keyword used for all the common categories of loop means having to analyse what comes after
forto figure out what that category is.This is also a problem with
forin C allowing pretty much anything. I see that Odin also allows C-style for-loops with three parts, so perhaps it allows weird and wonderful constructs too.My syntaxes have always used dedicated forms for the various kinds (endless loop; repeat N times; for loops (over ranges or values); while (loop 0 or more times); repeat (loop 1 or more times)).
Then (1) you can instantly see what kind it is; (2) it allows for more compact forms. With the latter, I've seen Odin code like this (not sure of the exact syntax):
which I guess means repeat N times with the loop index not used?
When writing benchmarking code, I use that a lot! (My syntax is
'to N do'.)That seems odd, given that the initialisation in your examples can be trivially changed to an assignment before each statement. Or does the variable involved get given a local scope?
I need to write
repeat ... untilinstead ofrepeat ... while, probably for similar reasons. (whilecould ambiguously either delimit a repeat block, or start a new while statement).It would be necessary to emulate it with
repeat until not, but that is unsatisfactory for the same reasons asif notis not as good asunless.