[Pas2js] Possible feature? keep the original JS overload behavior
Michael Van Canneyt
michael at freepascal.org
Tue Dec 25 09:51:33 CET 2018
On Mon, 24 Dec 2018, silvioprog wrote:
> 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 ...
I would then suggest to use "undefined" ?
procedure f(w: Integer = undefined); overload; external name 'f';
it exists in javascript, the meaning is clear, I think.
Michael.
More information about the Pas2js
mailing list