Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Overloaded function problem / wrong JavaScript output
Thu, Jul 27 2017 3:45 AMPermanent Link

Michael Dreher

I've declared classes and overloaded functions

 // type TCell = class end;
 //      TCellIterator = class public procedure Reset; end;
 //
 // function IFF(condition : boolean; const c1, c2 : TCell) : TCell;
 // function IFF(condition : boolean; i1, i2 : integer) : integer;

and applied the IFF function

 // procedure TCellIterator.Reset;
 // var i : integer;
 // begin                          
 //   i := IFF(3 > 0, 0, -1);
 // end;

The JS output is

 // cells_tcelliterator.$p.reset = function()
 // {
 //    var $t = this, i;
 //    i = (3 > 0, 0, -1); // (*)
 // };

(*) is valid JavaScript; an assignment to a comma operator expression resulting to -1. But I expected an assignment to the return value of a function call. The function name is missing here.

The IFF functions are implemented in different units. When I merge both functions into a single unit, the JS output is correct. The source code is in the attachment.

Michael Dreher



Attachments: Example.zip
Thu, Jul 27 2017 10:46 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< (*) is valid JavaScript; an assignment to a comma operator expression resulting to -1. But I expected an assignment to the return value of a function call. The function name is missing here. >>

I'll check it out.

Tim Young
Elevate Software
www.elevatesoft.com
Image