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

silvioprog silvioprog at gmail.com
Fri Dec 21 20:41:34 CET 2018


On Fri, Dec 21, 2018 at 3:58 PM Mattias Gaertner via Pas2js <
pas2js at lists.freepascal.org> wrote:

> On Fri, 21 Dec 2018 15:19:50 -0300
> silvioprog <silvioprog at gmail.com> wrote:
>
> >[...]
> > function foo; varargs 2; ...
> >
> > I never saw a compiler/language limiting the arguments in a variadic
> > function, but ... ๐Ÿ˜€
>
> Yes, what is needed is a procedure modifier or directive to omit
> passing default values.
>

Perfect!

Or both options. For example, in some cases (small JS libraries) we can use
it:

procedure foo(a: integer = 0; b: integer = 0); external;
some_new_directive_we_will_provide; ...
procedure bar(a: integer = 0; b: integer = 0); external;
some_new_directive_we_will_provide; ...

or (big JS library containing a lot of functions in their APIs):

{$SOME_NEW_DIRECTIVE_WE_WILL_PROVIDE ON}

procedure foo(a: integer = 0; b: integer = 0); external; ...
procedure bar(a: integer = 0; b: integer = 0); external; ...

SOME_NEW_DIRECTIVE_WE_WILL_PROVIDE = some new keyword or switch name in a
single intuitive word.

Keep in mind that code should be editable in Delphi IDE too. Maybe
> misusing a calling convention?
>

They will play on Delphi like a charm. :-)


> >[...]
> > I probably will change my transpiler copy allowing to omit the default
> > parameters in the generated script. ๐Ÿ˜…
>
> The power of open source. :)
>

oh yes! ๐Ÿ˜€

I'm asking some other friends via telegram/whatsapp to check possible new
ideas to share, but a new keyword (for single function) and a switch (for
the entire unit) sounds very good.

-- 
Silvio Clรฉcio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20181221/e877f193/attachment-0001.html>


More information about the Pas2js mailing list