Recent

Author Topic: [SOLVED] Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?  (Read 1446 times)

Hartmut

  • Hero Member
  • *****
  • Posts: 1135
I have a unit which for compatibility reasons has {$mode TP} = Turbo Pascal Mode. Now I want to use 'array of const' in this unit, if possible. For most features there is a switch like {$modeswitch xyz} to enable such things, but I found no one for 'array of const'.

Does it not exist or how is it named? Thanks in advance.
« Last Edit: November 21, 2022, 10:50:28 am by Hartmut »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?
« Reply #1 on: November 20, 2022, 03:35:28 pm »
https://wiki.lazarus.freepascal.org/Basic_Pascal_Tutorial/Chapter_1/Constants
This is how to use such in FPC. I hope that answers your question.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Hartmut

  • Hero Member
  • *****
  • Posts: 1135
Re: Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?
« Reply #2 on: November 20, 2022, 05:21:33 pm »
Thank you KodeZwerg for your reply, but it seems that we misunderstood. I'm searching for a special {$modeswitch xyz} to enable 'array of const' in {$mode TP} which is not contained in your link.

440bx

  • Hero Member
  • *****
  • Posts: 6491
Re: Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?
« Reply #3 on: November 20, 2022, 05:37:17 pm »
I'm searching for a special {$modeswitch xyz} to enable 'array of const' in {$mode TP} which is not contained in your link.
I could be wrong but, I don't think the "array of const" construction is available in TP mode.  I believe "array of const" was introduced with Delphi which leaves TP out of luck.

Hopefully one of the FPC developers can confirm or, shoot that down, as appropriate.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 19165
  • Glad to be alive.
Re: Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?
« Reply #4 on: November 20, 2022, 06:57:20 pm »
You are right, mode tp or fpc does not work. You will need mode delphi or objfpc.
objects are fine constructs. You can even initialize them with constructors.

Hartmut

  • Hero Member
  • *****
  • Posts: 1135
Re: Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?
« Reply #5 on: November 20, 2022, 07:03:27 pm »
I'm searching for a special {$modeswitch xyz} to enable 'array of const' in {$mode TP} which is not contained in your link.
I could be wrong but, I don't think the "array of const" construction is available in TP mode.  I believe "array of const" was introduced with Delphi which leaves TP out of luck.
Thank you 440bx for your answer, but as you write, you are not sure. There are many compiler features, which can be enabled in TP Mode via a specific {$modeswitch xyz}. I hope that this is the case also for 'array of const'...

Quote
Hopefully one of the FPC developers can confirm or, shoot that down, as appropriate.
Yes, I hope that too.

Hartmut

  • Hero Member
  • *****
  • Posts: 1135
Re: Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?
« Reply #6 on: November 20, 2022, 07:05:42 pm »
You are right, mode tp or fpc does not work. You will need mode delphi or objfpc.
Thank you Thaddy. Please excuse the question: how sure are you, that no {$modeswitch xyz} exists for that?

440bx

  • Hero Member
  • *****
  • Posts: 6491
Re: Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?
« Reply #7 on: November 20, 2022, 07:13:18 pm »
Thank you 440bx for your answer, but as you write, you are not sure.
You're welcome and, you're right, I am not sure.  No list of modeswitch(es) I've looked at seemed related to "array of const", hence the "conclusion".

FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6395
  • Compiler Developer
Re: Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?
« Reply #8 on: November 20, 2022, 10:46:06 pm »
I have a unit which for compatibility reasons has {$mode TP} = Turbo Pascal Mode. Now I want to use 'array of const' in this unit, if possible. For most features there is a switch like {$modeswitch xyz} to enable such things, but I found no one for 'array of const'.

Does it not exist or how is it named? Thanks in advance.

The array of const feature is bound to the modeswitch ObjPas which is enabled by default in modes ObjFPC, Delphi and MacPas. Enabling that in mode TP will significantly change how the code behaves and you could just as well convert your unit to mode Delphi or ObjFPC then.

Hartmut

  • Hero Member
  • *****
  • Posts: 1135
Re: Which {$modeswitch xyz} enables 'array of const' in {$mode TP} ?
« Reply #9 on: November 21, 2022, 10:50:03 am »
Thank you very much PascalDragon for that very clear and precise answer.

 

TinyPortal © 2005-2018