Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-03

Multiple variable initialization

27 messages · 14 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ondrej Pokorny

Is there a reason why multiple variable initialization is forbidden?

program Test;
var
   A: Integer = 0;    // allowed
   B, C: Integer = 0; // not allowed
begin
end.

Will a patch be applied that allows it?

Ondrej

Sven Barth
to Anthony Walter

Anthony Walter schrieb am Sa., 24. März 2018, 14:51:

Show quoted text 8 lines
If you were going to patch I'd also consider allowing: program Test; var B, C: Integer = 0, 1; // sets B = 0, and C = 1 begin end.

No, that is only confusing.

Regards,
Sven

Mattias Gaertner
to Michael Van Canneyt
Show quoted text 11 lines
On Sat, 24 Mar 2018, Ondrej Pokorny wrote: > Is there a reason why multiple variable initialization is forbidden? > > program Test; > var >   A: Integer = 0;    // allowed >   B, C: Integer = 0; // not allowed I think this is confusing to read. Are B and C both initialized, or only B ?

The "integer" is applied to both. It would be inconsistent to apply the =0 only to C.

Javascript also does not allow this, I think, and for once with good reason.

Since when is JS a role model for Pascal?

Mattias

Ondrej Pokorny
to Michael Van Canneyt: I think this is confusing to read. Are B and C both initialized, or only B ? Javascript…
Michael Van Canneyt wrote 11 lines
On Sat, 24 Mar 2018, Ondrej Pokorny wrote: > Is there a reason why multiple variable initialization is forbidden? > > program Test; > var >   A: Integer = 0;    // allowed >   B, C: Integer = 0; // not allowed I think this is confusing to read. Are B and C both initialized, or only B ?

It's not Mattias said, Integer is both applied to B and C, so should be "= 0".

Javascript also does not allow this, I think, and for once with good reason.

Well I cannot think of a good reason to disallow it :) And nobody has given a good reason yet.

Ondrej

Ozz Nixon
to Mattias Gaertner: On Sat, 24 Mar 2018 15:41:15 +0100 (CET) The "integer" is applied to both. It would be…

Actually (for clarity) JavaScript does allow multi-initialization, however, does not require type:

var a=0,b=0,c=0; // all are zero
// and if your presetting to zero due to Pascal not pre-initializing
variables, javascript does, so:
var a,b,c; // all are zero
var a=b=c=1; // C and most JavaScript engines all three are 1
var a,b,c=2; // in certain JavaScript engines only initializes C ==2, a and
b are zero.
some Pascal Dialets do support
var a:=b:=c:=3; // all are 3

Ozz

AM Mattias Gaertner wrote 29 lines
On Sat, 24 Mar 2018 15:41:15 +0100 (CET) Michael Van Canneyt wrote: > On Sat, 24 Mar 2018, Ondrej Pokorny wrote: > > > Is there a reason why multiple variable initialization is forbidden? > > > > program Test; > > var > > A: Integer = 0; // allowed > > B, C: Integer = 0; // not allowed > > I think this is confusing to read. > Are B and C both initialized, or only B ? The "integer" is applied to both. It would be inconsistent to apply the =0 only to C. > Javascript also does not allow this, I think, and for once with good reason. Since when is JS a role model for Pascal? Mattias _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Ondrej Pokorny
Alexander Grotewohl wrote
The patch is to put them on separate lines. Preferably with meaningful comments for each. If FPC was changed at the whim of every programmer we'd end up with a huge mess that no longer resembles pascal.

Please tell me who decides about the borderline between whim and usefulness.

E.g. FPC supports initializing local variables, which Delphi and (if I am not mistaken) ISO Pascal don't support:

procedure Test;
var
   A: Integer = 0;
begin
end;

Is it a whim as well? If FPC has this extension, why not to support

procedure Test;
var
   A, B: Integer = 0;
begin
end;

?

Ondrej

Alexander Grotewohl
to Ondrej Pokorny

It sounds more like you're making a case for all integers to be initialized to zero by default. I still fail to see any practical uses other than wanting to not type "integer" twice.

Alex

Ondrej Pokorny wrote 31 lines
On 24.03.2018 15:46, Alexander Grotewohl wrote: > The patch is to put them on separate lines. Preferably with > meaningful comments for each. If FPC was changed at the whim of every > programmer we'd end up with a huge mess that no longer resembles pascal. Please tell me who decides about the borderline between whim and usefulness. E.g. FPC supports initializing local variables, which Delphi and (if I am not mistaken) ISO Pascal don't support: procedure Test; var   A: Integer = 0; begin end; Is it a whim as well? If FPC has this extension, why not to support procedure Test; var   A, B: Integer = 0; begin end; ? Ondrej _______________________________________________ fpc-devel maillist  -  http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Florian Klaempfl
to Ondrej Pokorny: Is there a reason why multiple variable initialization is forbidden? program Test; var  …
Ondrej Pokorny wrote 10 lines
Is there a reason why multiple variable initialization is forbidden? program Test; var   A: Integer = 0;    // allowed   B, C: Integer = 0; // not allowed begin end. Will a patch be applied that allows it?

As the first one is supported, I see no logical reason the second shouldn't be supported, of course assigning 0 to B and C.

Jonas Maebe
to Ondrej Pokorny: Please tell me who decides about the borderline between whim and usefulness. E.g. FPC…
Ondrej Pokorny wrote 7 lines
On 24.03.2018 15:46, Alexander Grotewohl wrote: > The patch is to put them on separate lines. Preferably with meaningful > comments for each. If FPC was changed at the whim of every programmer > we'd end up with a huge mess that no longer resembles pascal. Please tell me who decides about the borderline between whim and usefulness.

It's in the eye of the beholder. Personally, I don't think it's a good extension either. Variable lists followed by a type are a fundamental part of the language and appear everywhere (variable lists, field declarations, parameter lists). On the other hand, a single constant that initialises multiple variables in a single statement does not exist anywhere else in the language. Therefore, adding it in one place would definitely be the wrong way to go about it. You'd also have to support it at least for record field initialisers and default parameters.

When seeing that compound initialisation/declaration statement for the first time, my first reflex was to interpret the initialisation as only applying to the final variable, no matter how useless that would make the language extension. As someone else posted, even languages that do allow multiple variables to be assigned in a single statement use a different syntax than the one to indicate that all variables have the same type. Having to switch your frame of mind when reading one particular family of expressions is bad for productivity. Everything should be as consistent as possible.

In the end, pretty much every extra language feature makes both the compiler and the language more complex. Therefore, I think the question for language extensions should never be "is there a good reason not to allow this", but "is it really necessary to allow this"? I.e., does it make things much easier to read, less error prone to write, and/or increase productivity a lot. I don't think the answer is "yes" for any of these questions as far as this extension is concerned.

Jonas

R0b0t1
to Jonas Maebe
Jonas Maebe wrote 8 lines
In the end, pretty much every extra language feature makes both the compiler and the language more complex. Therefore, I think the question for language extensions should never be "is there a good reason not to allow this", but "is it really necessary to allow this"? I.e., does it make things much easier to read, less error prone to write, and/or increase productivity a lot. I don't think the answer is "yes" for any of these questions as far as this extension is concerned.

For the record the Oberon languages were designed with this philosophy in mind, and language changes only ever removed functionality (which did not happen often). Those languages never saw wide adoption but are very interesting specimens of engineering.

I might agree with an addition similar to Python's tuple unpacking in assignment, which would allow multiple assignment but require multiple values:

var
  A, B: Integer = 0, 1;
  C, D: Integer = 0, 0;

However in some languages this is without good precedent or justification within the language, and seems like an unnatural bolted-on feature. Far more important I think is partial initialization of arrays and records.

Cheers,
R0b0t1

Ondrej Pokorny
to Jonas Maebe: It's in the eye of the beholder. Personally, I don't think it's a good extension either.…
Jonas Maebe wrote
You'd also have to support it at least for record field initialisers

and default parameters.

Oh yes, I'd also love to write

procedure Test(const A, B, C, D: Integer = 0);

instead of

procedure Test(const A: Integer = 0; const B: Integer = 0; const C:
Integer = 0; const D: Integer = 0);
Jonas Maebe wrote 7 lines
In the end, pretty much every extra language feature makes both the compiler and the language more complex. Therefore, I think the question for language extensions should never be "is there a good reason not to allow this", but "is it really necessary to allow this"? I.e., does it make things much easier to read, less error prone to write, and/or increase productivity a lot. I don't think the answer is "yes" for any of these questions as far as this extension is concerned.

Sorry I forgot to supply my real world example - I need to initialize local string parameters to empty strings:

procedure Test;
var
   A, B, C, D, E, F: string;
begin
   A := '';
   B := '';
   C := '';
   D := '';
   E := '';
   F := '';
// ....
end;

becomes:

procedure Test;
var
   A, B, C, D, E, F: string = '';
begin
   // ....
end;

Yes, both examples are much easier to read. You cannot convince me they are not.

Jonas Maebe wrote
When seeing that compound initialisation/declaration statement for

the first time, my first reflex was to interpret the initialisation as only applying to the final variable, no matter how useless that would make the language extension. As someone else posted, even languages that do allow multiple variables to be assigned in a single statement use a different syntax than the one to indicate that all variables have the same type.

Could you please tell me what post do you refer to? I probably missed it.

If you are talking about Ozz Nixon's post and the C-syntax:
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.

int a=b=0; is not supported in gcc

JavaScript: I am not aware you can declare type of variable in JavaScript. The operator precedence is the same as in C: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence so var a=5,b=1; is logical and well documented like in C. Yes, the alternative syntax var a=b=1; is valid in JavaScript.

So in Pascal, var A, B, C: Integer = 0; makes perfect sense and undoubtedly means all three variables are initialized to 0

Ondrej

Ondrej Pokorny
to Florian Klaempfl: As the first one is supported, I see no logical reason the second shouldn't be supported,…
Florian Klaempfl wrote 13 lines
Am 24.03.2018 um 11:46 schrieb Ondrej Pokorny: > Is there a reason why multiple variable initialization is forbidden? > > program Test; > var >   A: Integer = 0;    // allowed >   B, C: Integer = 0; // not allowed > begin > end. > > Will a patch be applied that allows it? As the first one is supported, I see no logical reason the second shouldn't be supported, of course assigning 0 to B and C.

Good to know there's somebody with the same point-of-view. Thanks :)

Ondrej

Jonas Maebe
to Ondrej Pokorny: and default parameters. Oh yes, I'd also love to write procedure Test(const A, B, C, D:…
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.

Show quoted text 8 lines
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

Ralf Quint
to Sven Barth: Anthony Walter schrieb am Sa., 24. März 2018, 14:51: No, that is only confusing. Sven
Sven Barth wrote 13 lines
Anthony Walter < > schrieb am Sa., 24. März 2018, 14:51: If you were going to patch I'd also consider allowing: program Test; var B, C: Integer = 0, 1;  // sets B = 0, and C = 1 begin end. No, that is only confusing.

+1

Writing programs in Pascal should make them readable, not add more obfuscation methods.

Ralf

---
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Ozz Nixon
to Ondrej Pokorny: Good to know there's somebody with the same point-of-view. Thanks :) Ondrej

As an extension, it makes sense - but I would make it a forced command line switch and obscure $modeswitch. So the code can easily be ported to other pascal compilers, or versions of FPC down the road. I spend 8 to 12 hours a day porting Delphi (versions) of code to FPC. And the XE series really made a mess of the language. I spend hours in FPC's core code, as I am making my script engine compatible with FPC's code (to be the interpreter for FPC source)...

I agree, especially from a script world, I would expect to see:
var a,b,c,d,e:String='';
as it looks like a script engines extension to:
const a,b,c,d:String='';

// and in Delphi $J+ aka {$WRITEABLECONST ON} making constant read/write - you have basically produced what you are asking for. So, maybe FPC already supports this?

* Now side note, you can define variable types in JavaScript (wrote my own
ECMA compliant script engine in 2000 (DXJavaScript) for Delphi):
var x = new Number(0);
var y = new String("Hello World!");

Of course, x and y are JavaScript objects at their core - so they can be any type later in the code. But, JavaScript does support type definition in the code. Number==Float==Integer.

Ozz

PM Ondrej Pokorny wrote 22 lines
On 24.03.2018 16:51, Florian Klaempfl wrote: > Am 24.03.2018 um 11:46 schrieb Ondrej Pokorny: >> Is there a reason why multiple variable initialization is forbidden? >> >> program Test; >> var >> A: Integer = 0; // allowed >> B, C: Integer = 0; // not allowed >> begin >> end. >> >> Will a patch be applied that allows it? > As the first one is supported, I see no logical reason the second > shouldn't be supported, of course assigning 0 to B and C. Good to know there's somebody with the same point-of-view. Thanks :) Ondrej _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Michael Van Canneyt
to Ozz Nixon
Ozz Nixon wrote
As an extension, it makes sense - but I would make it a forced command line switch and obscure $modeswitch.

Modeswitched and command-line options only go so far.

The problem with this approach is that, if I see someone elses code, I still have the confusing code in front of my eyes.

Same with Generics and whatnot.
It's correct that I don't use have to use them, but I am confronted with the ugly-as-hell syntax in other people's code all the time.

No amount of modeswitches can stop this proliferation of ugly constructs...

Michael.

Ondrej Pokorny
to Jonas Maebe: Then there's not much point in discussing. I was. The C-syntax is indeed consequent, and…
Jonas Maebe wrote 7 lines
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.

I still don't understand how anybody can think that the syntax "var A, B: Integer = 0;" is unclear and doesn't immediately recognize that 0 is applied both to A and B. Honestly it would never come to my mind if you haven't raised this question.

As you Jonas said, Pascal syntax for initialization of variables/constants is a special one after all and therefore you do need to know it. Explaining/documenting the fact that you can initialize multiple variables/constants at once is one extra sentence. Just one sentence. In a documentation that you need to read anyway because the initialization syntax is unusual.

Anyway, my favorite example of non-pascalish syntax within FPC are the +=, -= etc. operators. I really don't understand how they made it into FPC if so many FPC developers are stubbornly against simple and helpful extensions :)

Ondrej

Florian Klaempfl
to Ondrej Pokorny
Ondrej Pokorny wrote 5 lines
Anyway, my favorite example of non-pascalish syntax within FPC are the +=, -= etc. operators. I really don't understand how they made it into FPC if so many FPC developers are stubbornly against simple and helpful extensions :)

The were added in ~1996 when I maintained FPC by applying patches to a source tree on my hd :) But to be honest, I am not sure if I accepted the patch today :)

Ozz Nixon
to Alexander Grotewohl: It sounds more like you're making a case for all integers to be initialized to zero by…

Pre pre-initialization, I do it as a compile option:

Modern Pascal v2.0.0 (LINUX,CPU64,X86_64,LITTLEENDIAN,1180323) Copyright (c) 2000..2017 by Ozz Nixon (Modern Pascal Solutions, LLC).
■ Produces Cross-Platform 32bit/64bit Encrypted Binaries.

/usr/bin/mp2 [options] sourcefile [modifiers]
options:
-2 286 instructions -3 386 instructions -6 64bit instructions -o objfpc compatible -g compile to binary -t syntax check only -p[0|1|2] Pack EXE -r<path> Resource dirs -v version display -q syntax & method check -? this screen -h history log

modifiers: (all are on by default)
-a- $A- Assert Support Off -m- $M- Auto-Initialization Off -b- $B- Boolean Short Circuit Off -o- $O- Overflow Checking Off -c- $C- New C Operators Off -p- $P- Auto-Properties Off -d- $D- Full Disposal Off -r- $R- Range Protection Off -f- $F- Autoinvoke Functions Off -s- $S- Enums Scoped Off -h- $H- Hint of unused variables Off -x- $X- Extended Syntax Off -j- $J- Constant Address Off -z- $Z- Case supports CONTINUE Off
-l- $L- Lazy Semicolon Off

All numeric values are 0, 0.0, Booleans 0 aka False, Strings = '' (blank), PChar and Pointers = Nil. * Now my product is to accent FPC not replace it in anyway. I use a separate code base, and use FPC to compile my compiler. My binaries are like .java or .Net managed binaries. I only have just over 1,000 end-users and we try to stick 100% compatible to Turbo Pascal 7, but support Delphi-isms and FPC-isms. It only takes a couple extra lines in asm to $M+ in my compiler (It has saved many customers who just assumed, I said "var a:longint" then a:=a+some_value (actually true PascalDevs never do that, it is my migrated clients who seem to insist on a+=some_value and then wonder why a!=some_value). So, I made MPC default to $M+.

For FPC, I would default to true Pascal, A is an address, you get whats there unless you initialize it, and most code I see, except for loops, A is never being assigned 0 its is always being assigned a value from input_source. So save the few uSec and don't pre-init.

My 2 cents from the script world...
O.

AM Alexander Grotewohl wrote 44 lines
It sounds more like you're making a case for all integers to be initialized to zero by default. I still fail to see any practical uses other than wanting to not type "integer" twice. Alex On 03/24/2018 11:20 AM, Ondrej Pokorny wrote: > On 24.03.2018 15:46, Alexander Grotewohl wrote: >> The patch is to put them on separate lines. Preferably with >> meaningful comments for each. If FPC was changed at the whim of every >> programmer we'd end up with a huge mess that no longer resembles pascal. > > Please tell me who decides about the borderline between whim and > usefulness. > > E.g. FPC supports initializing local variables, which Delphi and (if I > am not mistaken) ISO Pascal don't support: > > procedure Test; > var > A: Integer = 0; > begin > end; > > Is it a whim as well? If FPC has this extension, why not to support > > procedure Test; > var > A, B: Integer = 0; > begin > end; > > ? > > Ondrej > _______________________________________________ > fpc-devel maillist - > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Anton Shepelev
to Ondrej Pokorny: Is there a reason why multiple variable initialization is forbidden? program Test; var  …

Ondrej Pokorny:

Show quoted text 11 lines
Is there a reason why multiple variable initial- ization is forbidden? program Test; var A: Integer = 0; // allowed B, C: Integer = 0; // not allowed begin end. Will a patch be applied that allows it?

That means another complication of the language, to which it is not well suited, c.f. the C style:

   int A = 0, B = 1, C = 2;

Initialisation is a special and redundant way to as- sign a value to a variable. Is this mixing of dec- laration and action a good idea? Why not keep them separate?

If you must save vertical space, write your initial assignments on one line:

   var A, B, C: Integer;
   begin
      A := 1; B := 2; C := 3;
      { work }
   end;
Please, do not forward replies to my e-mail.
Anton Shepelev
to Florian Klaempfl: The were added in ~1996 when I maintained FPC by applying patches to a source tree on my…

Florian Klaempfl to Ondrej Pokorny:

Show quoted text 10 lines
> Anyway, my favorite example of non-pascalish > syntax within FPC are the +=, -= etc. operators. > I really don't understand how they made it into > FPC if so many FPC developers are stubbornly > against simple and helpful extensions :) The were added in ~1996 when I maintained FPC by applying patches to a source tree on my hd :) But to be honest, I am not sure if I accepted the patch today :)
On the other hand, '+=', '-=', '*=',  and  '/='  fit
perfectly with the genuine Wirthian operator ':='.
Please, do not forward replies to my e-mail.
Péter Gábor
to Ondrej Pokorny: Is there a reason why multiple variable initialization is forbidden? program Test; var  …

Hi!

I have bean read all of the emails in this topic and now I have to write :) :

If multiple type declaration (A, B: Integer) are allowed then this new feature would not make difficulty to learn. Especially if we compare it to generics, what is already in the language and required/requires to learn a new (and non-conventional) syntax.

If the question is (as Jonas said) that "Is it really necessary to allow this"? - NOT necessary, we can live without it BUT...

BUT if ask the sub-questions (by Jonas):
- Does it make things much easier to read? - YES
- Less error prone to write? - YES
- Increase productivity a lot? - YES

Sum of answers are absolutely YES!
The requested language feature is a good idea that can make our favorite language better in all manners.

You can see it if you (all) take a look at at the examples (from Ondrej) below:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -

OLD:

  procedure Test(const A: Integer = 0; const B: Integer = 0; const C:
Integer = 0; const D: Integer = 0);

NEW:

  procedure Test(const A, B, C, D: Integer = 0);

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -

OLD:

  procedure Test;
  var
    A, B, C, D, E, F: string;
  begin
    A := '';
    B := '';
    C := '';
    D := '';
    E := '';
    F := '';
  end;

NEW:

  procedure Test;
  var
    A, B, C, D, E, F: string = '';
  begin
  end;

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -

OLD-MIXED:

  procedure Test(const A: Integer = 0; const B: Integer = 0; const C:
Integer = 0; const D: Integer = 0);
  var
    E, F, G, H,,I, J: string;
  begin
    E := '';
    F := '';
    G := '';
    H := '';
    I := '';
    J := '';
  end;

NEW-MIXED:

  procedure Test(const A, B, C, D: Integer = 0);
  var
    E, F, G, H, I, J: string = '';
  begin
  end;

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -

And again, the requested language feature is a good idea that can make our favorite language better in all manners.

2018-03-24 11:46 keltezéssel, Ondrej Pokorny írta:

Show quoted text 9 lines
Is there a reason why multiple variable initialization is forbidden? program Test; var   A: Integer = 0;    // allowed   B, C: Integer = 0; // not allowed begin end.

Regards

Péter Gábor
Alexander Grotewohl
to Péter Gábor
uses SysUtils; // inttostr
procedure blank(a: array of pointer);
var
   i: longint;
begin
   for i:=low(a) to high(a) do
     // string(a[i]^):='';
     string(a[i]^):='silly ~~~~~~~ '+IntToStr(i);
end;
var
   s, i, l, {l,} y: string;
begin
   blank(, @i, @l, ,} @y]);
   writeln(s); writeln(i);
   writeln(l); writeln(l);
   writeln(y); // !!
end.
Péter Gábor wrote 108 lines
Hi! I have bean read all of the emails in this topic and now I have to write :) : If multiple type declaration (A, B: Integer) are allowed then this new feature would not make difficulty to learn. Especially if we compare it to generics, what is already in the language and required/requires to learn a new (and non-conventional) syntax. If the question is (as Jonas said) that "Is it really necessary to allow this"? - NOT necessary, we can live without it BUT... BUT if ask the sub-questions (by Jonas): - Does it make things much easier to read? - YES - Less error prone to write? - YES - Increase productivity a lot? - YES Sum of answers are absolutely YES! The requested language feature is a good idea that can make our favorite language better in all manners. You can see it if you (all) take a look at at the examples (from Ondrej) below: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OLD:   procedure Test(const A: Integer = 0; const B: Integer = 0; const C: Integer = 0; const D: Integer = 0); NEW:   procedure Test(const A, B, C, D: Integer = 0); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OLD:   procedure Test;   var     A, B, C, D, E, F: string;   begin     A := '';     B := '';     C := '';     D := '';     E := '';     F := '';   end; NEW:   procedure Test;   var     A, B, C, D, E, F: string = '';   begin   end; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OLD-MIXED:   procedure Test(const A: Integer = 0; const B: Integer = 0; const C: Integer = 0; const D: Integer = 0);   var     E, F, G, H,,I, J: string;   begin     E := '';     F := '';     G := '';     H := '';     I := '';     J := '';   end; NEW-MIXED:   procedure Test(const A, B, C, D: Integer = 0);   var     E, F, G, H, I, J: string = '';   begin   end; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - And again, the requested language feature is a good idea that can make our favorite language better in all manners. 2018-03-24 11:46 keltezéssel, Ondrej Pokorny írta: > Is there a reason why multiple variable initialization is forbidden? > > program Test; > var >   A: Integer = 0;    // allowed >   B, C: Integer = 0; // not allowed > begin > end. > Regards
Ondrej Pokorny
to Anton Shepelev: Ondrej Pokorny: That means another complication of the language, to which it is not well…
Anton Shepelev wrote
Initialisation is a special and redundant way to assign a value to a variable. Is this mixing of declaration and action a good idea? Why not keep them separate?

LOL, I am not the one who wants to introduce initialisation of variables to Pascal. For your information, implicit and explicit initialization of variables and fields are in Pascal already now.

Ondrej