Ok first, I must be pedantic (sorry 😅)
E.g. "for (a =1 ; a< 2 ; a = a +1)" <= that is a syntax.
I'd disagree thats far more than a syntax. It's much more powerful than either a pascal for loop. Take the following:
for (int cnt
=0;(cnt
=fread(fin
, &buff
, sizeof(buff
))) > 0; fwrite(fout
, &buff
, cnt
) { printf("Processing %d bytes\n", cnt
); }
If you want something like that, is a different question, but the C for syntax is immensly powerful. In the past I have written a complete Base64 decoder in a single for loop without a body. Am I proud of it? Yes, would I use it productively? Hell no xD
Also it's even more than just syntactic sugar around while, because take the following:
for (prep;cond;step) {
body;
}
Naively one could say it's basically just a wrapper around:
prep;
while (cond) {
body;
step;
}
But it's not because step is also executed even if you do a "continue". So it's much more than just syntactic sugar.
Btw. this is also the reason why the FPC for loop is more than just syntactic sugar, because it enforces the step on continue, and also does bound checks to avoid overflow errors. So the following:
for i:=maxint-3 to MaxInt do
Is not equivalent to:
for (int i=maxint-3; i<=maxint; ++i)
because the C code is due to overflow an infinite loop while the first one only does 3 steps.
But now about the main topic
Is shortening more than syntax?
Well it's part of a concept, it's called expression based programming and the underlying assumption is that if the programmer writes single expressions the code is simpler and less likely to devovle into spaghetti code, because you enforce a form of locality.
Often this is combined with the concept of constness. So for example, if you write:
const c = if cond then Value1 else Value2;
You have the value of c local to it's definition, and because it's const you cannot change it.
This means if you want to know what C is, you just need to look in one place, it's definition.
On the other hand if you write the following:
var c;
...
if cond then
c := Value1
else
c := Value2;
You now spread the same information over multiple lines with multiple statements. Simultaneously to allow this C must be a variable and can't be a constant, so you can e.g. through a typo, accidentally assign a new value to C, which if it were a constant would throw a compiler error.
If your language supports and enforces constness, complex expressions are necessary to utilize this feature.
FreePascal does not support this, because it would require inline const definitions, which the core development team is heavily against, so it is not that much of an issue, but for example in C where constness is baked into the typesystem, a ternary if operator makes much more sense.
Lastly this also often comes with the assumptions that it's better to expressly write down your conditions each line, instead of having one big block. E.g.
const c1 = if cond then Value1 else Value2;
const c2 = if cond then Value3 else Value4;
// Instead of
var c1, c2;
...
if cond then
begin
c1:=Value1;
c2:=Value3;
end
else
begin
c1:=Value2;
c2:=Value4;
end;
The idea is that the former makes it much easier to see what is happening logically while the second example mixes c1 and c2 together just because they share the same condition, even though their logic may be semantically completely unrealated.