[Pas2js] Question regarding the New() function (#34736)

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Dec 20 16:59:53 CET 2018


On Thu, 20 Dec 2018 12:41:04 -0300
silvioprog <silvioprog at gmail.com> wrote:

>[...]
> $mod.o =
> pas.JS.new$1(["foo","bar","object",pas.JS.new$1(["abc",123]),"array",new
> Array(1,2,3)]);
> 
> Any change to upgrade the transpiler to use this:
> 
>   o := new(
>     'foo', 'bar',
>     'object', new('abc', 123),
>     'array', TJSArray.new(1,2,3)
>   );
> 
> to generate this?:
> 
> $mod.o = {"foo":"bar","object":{"abc",123},"array":new Array(1,2,3)};

Both create the same JS object.

A compiler built in function would have the advantage that the args are
checked at compiletime.

Mattias


More information about the Pas2js mailing list