Recent

Author Topic: [Solved] Is it possible to const an argument passed by reference in FPC?  (Read 11848 times)

440bx

  • Hero Member
  • *****
  • Posts: 2623
Re: Is it possible to const an argument passed by reference in FPC?
« Reply #60 on: August 03, 2019, 12:27:00 am »
Then discussion went into untyped... I got lost... :o
I suggest _never_ using untyped parameters. 

An untyped parameter implicitly causes the caller to pass any data type by reference since the parameter has no type.  It's one of those "great ideas" from a compiler writer who inhaled too much leaded red paint fumes before reaching the keyboard.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 11137
Re: Is it possible to const an argument passed by reference in FPC?
« Reply #61 on: August 03, 2019, 08:17:09 am »
Tell that to C api writers too, please  :D But I mostly agree.
Btw I helped introduced OpaquePointer and a TOpaqueData - empty - record to avoid untyped. It is in 3.2.0. The ratio I had was for passing C structures around w/o changing them from Pascal code, although it is also used in the rtl and rtl-generics.

Some of the untyped stuff can be resolved with the above. It is in systemh.inc. Not Delphi compatible, though.
« Last Edit: August 03, 2019, 08:21:14 am by Thaddy »
You have morons, I am one, and you have morons squared.

PascalDragon

  • Hero Member
  • *****
  • Posts: 3652
  • Compiler Developer
Re: Is it possible to const an argument passed by reference in FPC?
« Reply #62 on: August 03, 2019, 10:11:54 am »
Then discussion went into untyped... I got lost... :o
I suggest _never_ using untyped parameters. 

An untyped parameter implicitly causes the caller to pass any data type by reference since the parameter has no type.  It's one of those "great ideas" from a compiler writer who inhaled too much leaded red paint fumes before reaching the keyboard.
*rolls eyes*

440bx

  • Hero Member
  • *****
  • Posts: 2623
Re: Is it possible to const an argument passed by reference in FPC?
« Reply #63 on: August 03, 2019, 10:53:13 am »
*rolls eyes*
Is that another "very useful" parameter passing convention supported by FPC too ?
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

munair

  • Hero Member
  • *****
  • Posts: 781
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Is it possible to const an argument passed by reference in FPC?
« Reply #64 on: November 27, 2021, 08:49:45 pm »
Then discussion went into untyped... I got lost... :o
I suggest _never_ using untyped parameters. 

An untyped parameter implicitly causes the caller to pass any data type by reference since the parameter has no type.  It's one of those "great ideas" from a compiler writer who inhaled too much leaded red paint fumes before reaching the keyboard.
:D
This thread was very helpful and inspirational at the same time.
keep it simple

 

TinyPortal © 2005-2018