* * *

Author Topic: Dynamic array extensions ?  (Read 4504 times)

taazz

  • Hero Member
  • *****
  • Posts: 5150
Re: Dynamic array extensions ?
« Reply #30 on: June 21, 2018, 10:00:10 pm »
Quote
Addendum to that: the "+" operator is now connected to a "ArrayOperators" modeswitch.

Thank you. Guess that is an acceptable solution.

Code: Pascal  [Select]
  1. {$modeswitch ArrayOperators-} // Note the "-"
Why is it "-" in this case rather than "OFF" ?
As far as I understand, + is an alias to on,  - an alias to off, (or vice versa) they are interchangeable, he only drawn your attention to the - because it is easy to miss, if he had used off instead then the note would not have been necessary.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

VTwin

  • Sr. Member
  • ****
  • Posts: 425
  • Former Turbo Pascal 3 user
Re: Dynamic array extensions ?
« Reply #31 on: June 22, 2018, 06:43:03 pm »
Quote
Addendum to that: the "+" operator is now connected to a "ArrayOperators" modeswitch.

Thank you. Guess that is an acceptable solution.

Code: Pascal  [Select]
  1. {$modeswitch ArrayOperators-} // Note the "-"
Why is it "-" in this case rather than "OFF" ?

https://www.freepascal.org/docs-html/prog/progsu105.html

Quote
The syntax is as follows:
{$MODESWITCH XXX} 
{$MODESWITCH XXX+} 
{$MODESWITCH XXX-}

The first two will switch on feature XXX, the last one will switch it off.

A mode switch seems like a good solution. Thanks!
“Talk is cheap. Show me the code.” Linus Torvalds

Lazarus 1.8.4, FPC 3.0.4
macOS 10.11.5 (32 bit Carbon, working on Cocoa) 
Windows 7 (64 bit)
Ubuntu 16.04.3 (64 bit)

PascalDragon

  • Full Member
  • ***
  • Posts: 130
  • Compiler Developer
Re: Dynamic array extensions ?
« Reply #32 on: June 22, 2018, 10:36:52 pm »
Quote
Addendum to that: the "+" operator is now connected to a "ArrayOperators" modeswitch.

Thank you. Guess that is an acceptable solution.

Code: Pascal  [Select]
  1. {$modeswitch ArrayOperators-} // Note the "-"
Why is it "-" in this case rather than "OFF" ?

Because modeswitches currently don't support ON/OFF, only +/- (the latter can also be used with other switches, like e.g. $ScopedEnums).  :-[

ASBzone

  • Jr. Member
  • **
  • Posts: 51
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: Dynamic array extensions ?
« Reply #33 on: June 23, 2018, 01:31:03 am »
Addendum to that: the "+" operator is now connected to a "ArrayOperators" modeswitch.

If the modeswitch is active then the "+" operator overload is not possible and the compiler will warn if such an overload is in scope. If the modeswitch is not set, then everything is as before.

The modeswitch is enabled by default in Delphi modes, because that's why the feature was added. To disable the modeswitch there use this:

Code: Pascal  [Select]
  1. {$mode Delphi}
  2. {$modeswitch ArrayOperators-} // Note the "-"

Awesome.  Much appreciated.
-ASB: https://www.BrainWaveCC.com

Lazarus 1.8.4 (32-bit) + FPC 3.0.4
Windows 10 Pro x64, Version 1803 (Build 17134.5)

(Technically, I logon to these forums from multiple versions of Windows Pro/Enterprise...)

PascalDragon

  • Full Member
  • ***
  • Posts: 130
  • Compiler Developer
Re: Dynamic array extensions ?
« Reply #34 on: June 23, 2018, 01:49:56 pm »
Because modeswitches currently don't support ON/OFF, only +/- (the latter can also be used with other switches, like e.g. $ScopedEnums).  :-[

And now FPC also supports ON and OFF in modeswitches :D

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus