[fpc-pascal] Next language feature for pas2js...
Ryan Joseph
ryan at thealchemistguild.com
Tue May 1 11:04:08 CEST 2018
> On May 1, 2018, at 3:50 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
>
>
> As far as I know, all consts in Javascript are scoped ?
>
> If this is not the case, then of course we should allow it.
I think they added const. In the past I’ve seen using “let” but I don’t think that’s a real const if that matters or not.
>
> You must define the type to something the compiler knows, so the compiler knows what operations it can do.
>
> If you really do not know the type, use JSValue. But there is little you can
> do with a JSValue except assign or typecast it.
I see. So the type is really for the parser but it gets passed on as the real name to JS.
>
> You are mistaken where that is concerned.
>
> See above: Most APIs _do_ specify a type. You must look it up. Have a look
> at the web.pas or js.pas or even libjquery.pas units. Most identifiers have
> a type, the use of JSValue is quite limited.
>
> Read-only Attributes can be translated to read-only properties.
>
> The above would be
>
> Type
> WebGLActiveInfo = class external name 'WebGLActiveInfo'
> Private
> fSize : GLint; external name 'size';
> ftype: GLEnum; external name 'type';
> fName : DOMString ; external name 'name';
> Public
> Property size : GLInt Read FSize;
> Property &type : GLEnum Read fType;
> Propert Name : DomString read FName;
> end;
Interface is just a class? That makes sense but “dictionary” is a real type I assume because I know JS has “associative arrays” or hash maps. How do those work in Pascal?
Shouldn’t there be some automatic tool to parse JS api's to Pascal then? Makes sense so API’s like this can be dumped out easily.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list