Forum > Suggestions

multiple variable initialisation

(1/3) > >>

speter:
At present you can write something like:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure foo;var  a : integer = 5;  b : integer = 5;begin  //...end;
Would it be possible to extend this to allow?

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure foo;var  a,b : integer = 5; // initialise 2 or more variables to some valuebegin  //...end;
Or is this a really bad idea for some reason!?

cheers
S.

dseligo:
I think this was suggested multiple times already, e.g.: https://forum.lazarus.freepascal.org/index.php/topic,49505.0.html

speter:

--- Quote from: dseligo on June 06, 2021, 11:03:54 am ---I think this was suggested multiple times already, e.g.: https://forum.lazarus.freepascal.org/index.php/topic,49505.0.html

--- End quote ---
Thanks for that. I guess what goes around, comes back every year. Or something.

No worries.

cheers
S.

Kays:

--- Quote from: speter on June 06, 2021, 10:02:32 am ---[…] Would it be possible to extend this to allow? […]
--- End quote ---
In Extended Pascal, which the FPC plans to support in a hundred years, it is legal to write:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var        a, b: integer value 5;The GPC already compiles that and it works as expected.

Leledumbo:
The rule with regard to extension has stood for long: https://www.freepascal.org/faq.var#extensionselect

--- Quote ---The extension must have real value. Anything that is only a shorter notation does not apply, unless it is out of compatibility with an existing Pascal/Delphi codebase. Practically it means it must make something possible that cannot be done otherwise or be a compatibility item

--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version