Recent

Author Topic: bool1, bool2, bool3 : boolean = false; ?  (Read 8159 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
bool1, bool2, bool3 : boolean = false; ?
« on: November 21, 2014, 09:42:50 pm »
Hello.

I woud not be against =>
Code: [Select]
Var
bool1, bool2, bool3 : boolean = false;

Nor against =>
Code: [Select]
Var
int1, int2, int3 : integer = 0;

Thanks.

Fre;D
« Last Edit: November 21, 2014, 09:49:44 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #1 on: November 22, 2014, 12:37:55 am »
Is there a reason why this was never introduced into pascal?
Be the difference that makes a difference

Windsurfer

  • Sr. Member
  • ****
  • Posts: 368
    • Windsurfer
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #2 on: November 22, 2014, 10:21:44 am »
It is a neat idea, and would make it more likely that variables are initialised correctly.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #3 on: November 22, 2014, 02:49:51 pm »
Afaik mode objfpc has something like that. I never use it because IMHO it is dangerous. (same syntax for global and local variables, when globals are initialized only once, and locals every time they run, mistakes are too easily made)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #4 on: November 22, 2014, 03:03:38 pm »
Afaik mode objfpc has something like that. I never use it because IMHO it is dangerous. (same syntax for global and local variables, when globals are initialized only once, and locals every time they run, mistakes are too easily made)
ObjFPC cannot compile this:
Code: [Select]
var
  i,j,k: Integer = 255;
begin
  WriteLn(i,' ',j,' ',k);
end.
Are you referring to the variable initialization only or the multiple variable initialization?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #5 on: November 22, 2014, 03:06:24 pm »
Are you referring to the variable initialization only or the multiple variable initialization?

The initialization itself. From what I remember when it was introduced the disallow of multiple at once is on purpose. Because I didn't like the feature at all, I didn't track it with much attention though, so I don't remember the details.


Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #6 on: November 22, 2014, 03:23:22 pm »
Are you referring to the variable initialization only or the multiple variable initialization?

The initialization itself. From what I remember when it was introduced the disallow of multiple at once is on purpose. Because I didn't like the feature at all, I didn't track it with much attention though, so I don't remember the details.
Ah OK. Yes, I hope multiple initialization will never be supported unless it has a better syntax (like, for instance, Lua, with stricter rule) instead of the one in this topic.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #7 on: November 22, 2014, 04:21:12 pm »
IMHO people waste more time on threads like these than they will ever earn back with such feature.

It is borderline makeup under the guise of productivity. In general people always want to improve the language while the heavy lifting must be done in the libraries.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #8 on: November 22, 2014, 05:40:14 pm »
Quote
IMHO people waste more time on threads like these than they will ever earn back with such feature.

Hum... =>
Code: [Select]
var
  a : Integer = 255;
  b : Integer = 255;
  c : Integer = 255;
  d : Integer = 255;
  e : Integer = 255;
  f : Integer = 255;
  g : Integer = 255;
  h : Integer = 255;
  i : Integer = 255;
  j : Integer = 255;
  k : Integer = 255;
vs
Code: [Select]
var
  a, b, c, d, e, f, g, h, i, j, k : Integer = 255;

 :-[
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #9 on: November 22, 2014, 05:52:48 pm »
Quote
IMHO people waste more time on threads like these than they will ever earn back with such feature.

Hum... =>
Code: [Select]
var
  a : Integer = 255;
  b : Integer = 255;
  c : Integer = 255;
  d : Integer = 255;
  e : Integer = 255;
  f : Integer = 255;
  g : Integer = 255;
  h : Integer = 255;
  i : Integer = 255;
  j : Integer = 255;
  k : Integer = 255;
vs
Code: [Select]
var
  a, b, c, d, e, f, g, h, i, j, k : Integer = 255;

 :-[

Learn about the fabulous "array" language concept :-)

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #10 on: November 22, 2014, 05:57:19 pm »
Quote
In general people always want to improve the language while the heavy lifting must be done in the libraries.

And i have a other suggestion too => Delete that Suggestions branch => they are not welcome and always boring  :-X...
« Last Edit: January 14, 2015, 09:45:51 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #11 on: November 22, 2014, 06:13:15 pm »
And i have a other suggestion too => Delete that the Suggestions branch => there are not welcome and always boring...

Could also depend on the quality of the suggestions :-) Anyway, language suggestions are supposed to be accompanied with patches.

Also note the "typing only" sentences in
http://www.freepascal.org/faq.var#extensionselect


Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: bool1, bool2, bool3 : boolean = false; ?
« Reply #12 on: November 22, 2014, 06:17:16 pm »
Quote
Anyway, language suggestions are supposed to be accompanied with patches.

There you win...   :-[
« Last Edit: January 14, 2015, 09:45:24 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018