Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Name Lookup Problem
Tue, Mar 20 2018 2:47 AMPermanent Link

Michael Dreher

I am getting a compiler error "function xyz does not exist", but I don't
know what's wrong with the code(complete project attached, using 2.06B11).

type
 TFloatFunc1 = function(f : double) : double;

 TVector = class public
   function Equals(const v : TVector) : boolean;
   function Map(f : TFloatFunc1) : TVector;
 end;

function DoubleTheValue(f : double) : double;
begin
 Result := f*f;
end;

procedure RunTest;
var b : boolean;
begin           
 b := TVector.Create.Map(DoubleTheValue).Equals(TVector.Create);
   // [Error] Main.wbs (42,27): The referenced variable, parameter, or function DoubleTheValue does not exist
end;

Michael Dreher



Attachments: CodeExample.zip
Tue, Mar 20 2018 6:25 AMPermanent Link

Matthew Jones

What happens if you assign the function to a variable and pass that in?


--

Matthew Jones
Tue, Mar 20 2018 6:35 AMPermanent Link

Michael Dreher

"Matthew Jones" wrote:

  // What happens if you assign the function to a variable and pass that in?

It compiles. Here are workarounds:

procedure RunTest_WorkAround;
var
 b : boolean;
 f : TFloatFunc1;
begin
 f := DoubleTheValue;
 b := TVector.Create.Map(f).Equals(TVector.Create);
end;

procedure RunTest_WorkAround2;
var
 v : TVector;
 b : boolean;
begin         
 v := TVector.Create.Map(DoubleTheValue);
 b := v.Equals(TVector.Create);
end;

Michael Dreher
Tue, Mar 20 2018 5:24 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< I am getting a compiler error "function xyz does not exist", but I don't know what's wrong with the code(complete project attached, using 2.06B11). >>

It's a bug - I'll make sure this is fixed in the upcoming 3.0 release.

Tim Young
Elevate Software
www.elevatesoft.com
Image