[Pas2js] Possible feature? keep the original JS overload behavior

silvioprog silvioprog at gmail.com
Mon Dec 24 23:31:32 CET 2018


On Mon, Dec 24, 2018 at 7:01 PM Mattias Gaertner via Pas2js <
pas2js at lists.freepascal.org> wrote:

> On Fri, 21 Dec 2018 22:50:01 +0100 (CET)
> Michael Van Canneyt <michael at freepascal.org> wrote:
>
> >[...]
> > > Why forbid it for Pascal functions?
> > The purpose of pas2js is to allow pascal to run in the browser.
> > The purpose is not to make pascal behave like Javascript.
> > I want to bend Javascript, not bend pascal. So if we really must bend
> > pascal to accomodate interaction with external JS code,
> > I prefer it limited to that use case alone :-)
>
> Good point.
>
> In that case the default value is not needed and syntax could be:
>
> procedure f(w: jsvalue = JSOmitArg); external name 'f';
>
> where JSOmitArg is a special value that is omitted.
> Advantage: no need to adapt Delphi/Lazarus.
>
> Mattias


That would be great.

Will it be compatible to other types? E.g:

procedure f(w: Integer = JSOmitArg); overload; external name 'f';
procedure f(w: string = JSOmitArg); overload; external name 'f';

In the example above only Integers and Strings are allowed in f().

p.s: JSDefault could be an option too. :-) E.g:

procedure f(w: JSValue = JSDefault); external ...

--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20181224/ad0e4fd3/attachment-0001.html>


More information about the Pas2js mailing list