Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2020-12

Nested functions or procedures

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

heliosroots

I am not able to use a nested function, if it is nested in a pascal class, I do not know if this behavior is normal. It works if it is nested in a simple function.

procedure AnimationFrame(ATime: double = 0);
begin
   ...
   window.requestAnimationFrame(@AnimationFrame);
end;
///Error: Incompatible type arg no. 1: Got "procedure(Double) of Object",
expected "procedure(Double)"

Reply by email

Michael Van Canneyt
to heliosroots
heliosroots wrote 13 lines
I am not able to use a nested function, if it is nested in a pascal class, I do not know if this behavior is normal. It works if it is nested in a simple function. procedure AnimationFrame(ATime: double = 0); begin ... window.requestAnimationFrame(@AnimationFrame); end; ///Error: Incompatible type arg no. 1: Got "procedure(Double) of Object", expected "procedure(Double)"

It depends on how the requestAnimationFrame was defined.

Change the definition on line 1993 of web.pas to

  TFrameRequestCallback = reference to procedure (aTime: TJSDOMHighResTimeStamp);

And it will work with both kinds of procedure.

I fixed it in SVN, rev. 1013.

Michael.

Reply by email