Recent

Author Topic: requiring "overload" modifier  (Read 799 times)

440bx

  • Hero Member
  • *****
  • Posts: 2561
requiring "overload" modifier
« on: October 06, 2021, 08:22:32 am »
Hello,

I was wondering if it was possible to instruct FPC to always require the "overload" modifier to overload functions.

IOW, is there some way to instruct the compiler to reject a function overload (even in the same unit) unless one or both of them are marked as "overload" ?

Thank you for your help.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 10993
Re: requiring "overload" modifier
« Reply #1 on: October 06, 2021, 08:41:08 am »
Change the mode to {$mode delphi}. That should do the trick.
(There may be a modeswitch for it too)
« Last Edit: October 06, 2021, 08:47:24 am by Thaddy »
The average programmer productivity is 4-5 hours per day. Peak performance 72 hours for short bursts. MTBF is 1 second or less.

PascalDragon

  • Hero Member
  • *****
  • Posts: 3524
  • Compiler Developer
Re: requiring "overload" modifier
« Reply #2 on: October 06, 2021, 08:46:44 am »
I was wondering if it was possible to instruct FPC to always require the "overload" modifier to overload functions.

IOW, is there some way to instruct the compiler to reject a function overload (even in the same unit) unless one or both of them are marked as "overload" ?

Use neither FPC nor ObjFPC mode as all other modes require the overload modifier.

440bx

  • Hero Member
  • *****
  • Posts: 2561
Re: requiring "overload" modifier
« Reply #3 on: October 06, 2021, 08:59:25 am »
Change the mode to {$mode delphi}. That should do the trick.
(There may be a modeswitch for it too)
Thank you Thaddy but, {$mode delphi} is something I really don't want to use.  I want my pchars to be pchars, not pwidechars (or panything else for that matter.)

Use neither FPC nor ObjFPC mode as all other modes require the overload modifier.
Thank you PascalDragon.  What mode should I use (including any modeswitches if necessary) to get the features of mode FPC and have the compiler require the use of the "overload" modifier ?  (please don't say "mode delphi".. <chuckle>)
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Bart

  • Hero Member
  • *****
  • Posts: 4516
    • Bart en Mariska's Webstek
Re: requiring "overload" modifier
« Reply #4 on: October 06, 2021, 09:21:52 am »
Thank you Thaddy but, {$mode delphi} is something I really don't want to use.  I want my pchars to be pchars, not pwidechars (or panything else for that matter.)

PChars are only PWideChars in {$mode DelphiUnicode}, not in plain {$mode Delphi} AFAIK.

Bart

PascalDragon

  • Hero Member
  • *****
  • Posts: 3524
  • Compiler Developer
Re: requiring "overload" modifier
« Reply #5 on: October 06, 2021, 01:34:55 pm »
Change the mode to {$mode delphi}. That should do the trick.
(There may be a modeswitch for it too)
Thank you Thaddy but, {$mode delphi} is something I really don't want to use.  I want my pchars to be pchars, not pwidechars (or panything else for that matter.)

PChar only is an alias of PWideChar if modeswitch UnicodeStrings is set and that is by default only the case for mode DelphiUnicode.

Use neither FPC nor ObjFPC mode as all other modes require the overload modifier.
Thank you PascalDragon.  What mode should I use (including any modeswitches if necessary) to get the features of mode FPC and have the compiler require the use of the "overload" modifier ?  (please don't say "mode delphi".. <chuckle>)

Then I'll say nothing, cause that does not exist. ;D

440bx

  • Hero Member
  • *****
  • Posts: 2561
Re: requiring "overload" modifier
« Reply #6 on: October 06, 2021, 01:49:25 pm »
PChar only is an alias of PWideChar if modeswitch UnicodeStrings is set and that is by default only the case for mode DelphiUnicode.
I get lost in what the various compilers do with pchars these days.  I occasionally have the opportunity to use Delphi Seattle and it obviously treats the pchars in my programs as pwidechar because I get a bunch of Asian characters instead of ascii.  With FPC, I declare a pchar and so far, it's always a pchar... that's really nice.


Then I'll say nothing, cause that does not exist. ;D
No problem.  I'll just live with not having the option of telling FPC to require the overload.  Much safer and predictable than setting modes I am unfamiliar with.  Thank you for the information and thank you to all those who contributed.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

 

TinyPortal © 2005-2018