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

silvioprog silvioprog at gmail.com
Fri Dec 21 21:21:29 CET 2018


I meant $OMITDEFAULTPARAMS or $NODEFAULTPARAMS. $NODEFAULTPARAMS sounds
good too.

On Fri, Dec 21, 2018 at 5:16 PM silvioprog <silvioprog at gmail.com> wrote:

> On Fri, Dec 21, 2018 at 4:59 PM silvioprog <silvioprog at gmail.com> wrote:
>
>> On Fri, Dec 21, 2018 at 4:54 PM Mattias Gaertner via Pas2js <
>> pas2js at lists.freepascal.org> wrote:
>>
>>> On Fri, 21 Dec 2018 20:17:04 +0100 (CET)
>>> Michael Van Canneyt <michael at freepascal.org> wrote:
>>
>>
> Dudes, possible ideas I checked with other friends:
>
> - *nodefaults* - new keyword: it allows to omit the default arguments in
> a single external or assembler function.
> - $OMIT_DEFAULT_PARAMS ON|OFF - new compiler switch: it allows to omit
> the default arguments in a single external or assembler function or in the
> entire unit.
>
> Some examples using the keyword:
>
> function foo(a: integer = 0; b: integer = 0); *nodefaults*; external name
> 'foo';
> function bar(a, b: integer = 0); *nodefaults*; external name 'bar';
>
> Note: since the 'nodefaults' was defined to 'bar', you can declare default
> params using the short way "a,b: integer = 0" or the verbose one "a:
> integer = 0; b: integer = 0".
>
> Some examples using the swtch:
>
> {$OMIT_DEFAULT_PARAMS ON}
>
> function foo(a: integer = 0; b: integer = 0); external name 'foo';
> function bar(a, b: integer = 0); external name 'bar';
> function foobar(a, b: integer = 0); assembler;
>
> All functions above allows to omit default params. Or:
>
> {$PUSH}{$OMIT_DEFAULT_PARAMS ON}
> function foo(a: integer = 0; b: integer = 0); external name 'foo';
> function bar(a, b: integer = 0); external name 'bar';
> {$POP}
> function foobar(a, b: integer = 0); assembler;
>
> only "foo()" and "bar()" allows to omit their params.
>
> What do you think?
>
> --
> Silvio Clécio
>


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


More information about the Pas2js mailing list