Recent

Author Topic: Initializing large constant  (Read 976 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 15643
  • Censorship about opinions does not belong here.
Re: Initializing large constant
« Reply #15 on: September 30, 2024, 11:24:55 am »
Zvoni,
illigal use of var...  %)
If I smell bad code it usually is bad code and that includes my own code.

Zvoni

  • Hero Member
  • *****
  • Posts: 2690
Re: Initializing large constant
« Reply #16 on: September 30, 2024, 11:34:08 am »
Zvoni,
illigal use of var...  %)
Huh? Works for me with FPC3.2.2-32Bit - Laz2.2.2-32Bit (Sorry, should have mentioned it?)
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Thaddy

  • Hero Member
  • *****
  • Posts: 15643
  • Censorship about opinions does not belong here.
Re: Initializing large constant
« Reply #17 on: September 30, 2024, 11:35:37 am »
What does the subject say?  O:-) My solution sticks to it...
If I smell bad code it usually is bad code and that includes my own code.

Zvoni

  • Hero Member
  • *****
  • Posts: 2690
Re: Initializing large constant
« Reply #18 on: September 30, 2024, 11:42:07 am »
What does the subject say?  O:-) My solution sticks to it...
Arrgghh..... Mea Culpa....missed that it's about a CONSTANT...

Yeah, your solution works, since it gets resolved during compile-time, not runtime
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

PascalDragon

  • Hero Member
  • *****
  • Posts: 5672
  • Compiler Developer
Re: Initializing large constant
« Reply #19 on: October 01, 2024, 11:01:53 pm »
The rest of the elements are nulls.

Please note that a array of Char can be considered a special case, because the compiler will essentially initialize it like a NUL-terminated string. For other array types this wouldn't even work, there you need to really provide an array declaration.

If we would have more ISO Extended Pascal support already then there'd be a solution for you:

Code: Pascal  [Select][+][-]
  1. type
  2.   TMyArr = array[0..8191] of Char;
  3. const
  4.   SPACE_ARRAY = TMyArr[otherwise ' '];

440bx

  • Hero Member
  • *****
  • Posts: 4535
Re: Initializing large constant
« Reply #20 on: October 01, 2024, 11:55:30 pm »
If we would have more ISO Extended Pascal support already then there'd be a solution for you:

Code: Pascal  [Select][+][-]
  1. type
  2.   TMyArr = array[0..8191] of Char;
  3. const
  4.   SPACE_ARRAY = TMyArr[otherwise ' '];
That would be very nice :)

Thank you for making it clear that, at least at this time, there is no simple/straightforward way to have the compiler initialize the constant as desired.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 15643
  • Censorship about opinions does not belong here.
Re: Initializing large constant
« Reply #21 on: October 02, 2024, 04:31:03 pm »
I have never seen that in the wild...
stick to my simple generator.
« Last Edit: October 02, 2024, 04:35:52 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5672
  • Compiler Developer
Re: Initializing large constant
« Reply #22 on: October 03, 2024, 01:37:06 pm »
I have never seen that in the wild...

Of course you haven't. There aren't that many compilers supporting ISO Extended Pascal after all.

Thaddy

  • Hero Member
  • *****
  • Posts: 15643
  • Censorship about opinions does not belong here.
Re: Initializing large constant
« Reply #23 on: October 03, 2024, 03:04:13 pm »
Well, I will ask Scott Franco. I understood - maybe from him - it was implemented in P5x.
In that case I probably already have it, unless it did not make it to the Pascal to  GNU C transpiler. (P5C).
If I smell bad code it usually is bad code and that includes my own code.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11763
  • FPC developer.
Re: Initializing large constant
« Reply #24 on: October 03, 2024, 05:13:09 pm »
Well, I will ask Scott Franco. I understood - maybe from him - it was implemented in P5x.
In that case I probably already have it, unless it did not make it to the Pascal to  GNU C transpiler. (P5C).

Afaik p5 was mostly about ISO 7185, not extended pascal.

p5c seems to also only list 7185 level 1 as status: https://sourceforge.net/p/pascal-p5c/wiki/Home/

Prospero and GPC are the extended pascal's gotos afaik.

Thaddy

  • Hero Member
  • *****
  • Posts: 15643
  • Censorship about opinions does not belong here.
Re: Initializing large constant
« Reply #25 on: October 03, 2024, 05:25:12 pm »
Marco it is P5x as a literal where the x means x, not a substitution char, but indicates extended pascal.
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018