Recent

Author Topic: Reference to function  (Read 2150 times)

julkas

  • Guest
Reference to function
« on: July 14, 2019, 12:20:47 pm »
How I can convert Delphi code containing reference to function (with generics) to Free Pascal 3.0.4?
Thanks.
« Last Edit: July 14, 2019, 01:45:34 pm by julkas »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11459
  • FPC developer.
Re: Reference to function
« Reply #1 on: July 14, 2019, 12:24:34 pm »
Not yet. Reference to is anonymous methods, which is not implemented yet. Release or trunk.

julkas

  • Guest
Re: Reference to function
« Reply #2 on: July 14, 2019, 12:45:04 pm »
Not yet. Reference to is anonymous methods, which is not implemented yet. Release or trunk.
I want something like 
Code: Pascal  [Select][+][-]
  1. type
  2.   TProcedure<TA, TB> = reference to procedure (a: TA; b: TB);
  3.  
where TA, TB - generics

PascalDragon

  • Hero Member
  • *****
  • Posts: 5486
  • Compiler Developer
Re: Reference to function
« Reply #3 on: July 14, 2019, 01:09:29 pm »
As long as you don't rely on it being a function reference (which requires anonymous functions which are - as marcov wrote - not yet implemented) you can use a normal procedure or method variable (depending on your use case):
Code: Pascal  [Select][+][-]
  1. type
  2.   TProcedure<TA, TB> = procedure(a: TA; b: TB);
  3.   TMethod<TA, TB> = procedure(a: TB; b: TB) of object;

julkas

  • Guest
Re: Reference to function
« Reply #4 on: July 14, 2019, 02:24:13 pm »
As long as you don't rely on it being a function reference (which requires anonymous functions which are - as marcov wrote - not yet implemented) you can use a normal procedure or method variable (depending on your use case):
Code: Pascal  [Select][+][-]
  1. type
  2.   TProcedure<TA, TB> = procedure(a: TA; b: TB);
  3.   TMethod<TA, TB> = procedure(a: TB; b: TB) of object;
@PascalDragon Thanks.

 

TinyPortal © 2005-2018