[fpc-devel] Multiple variable initialization

Jonas Maebe jonas at freepascal.org
Sat Mar 24 18:40:59 CET 2018


On 24/03/18 17:54, Ondrej Pokorny wrote:
> Yes, both examples are much easier to read. You cannot convince me they 
> are not.

Then there's not much point in discussing.

> If you are talking about Ozz Nixon's post and the C-syntax:

I was.

> int a, b, c;
> int a=0, b=0, c=0;
> 
> What different syntax do you talk about? The syntax is consequent - it's 
> about operator precedence. Comma is evaluated after the assignment ( 
> http://en.cppreference.com/w/cpp/language/operator_precedence ) - this 
> is well documented. A similar scenario for Pascal would be: var A = 0, B 
> = 0, C = 0: Integer; But you know this is not Pascal syntax.

The C-syntax is indeed consequent, and that is what I referred to: the 
assignments work the same way as elsewhere in the program, so multiple 
initialisations are just as clear as single initialisations there. In 
Pascal, you have a special syntax for initialised variables/constants, 
and hence extending it to work on multiple variables/fields does not 
have the advantage that you subconsciously immediately know what happens 
based on your knowledge of the rest of the language.


Jonas



More information about the fpc-devel mailing list