[Pas2js] Random bugs and observations

Ryan Joseph ryan at thealchemistguild.com
Fri May 11 09:28:55 CEST 2018



> On May 11, 2018, at 1:41 PM, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
> 
> On Fri, 11 May 2018 12:23:03 +0700
> Ryan Joseph <ryan at thealchemistguild.com> wrote:
> 
>> Sorry for the long list. :)
> 
> Who writes lists gets short answers. If you want long answers create
> proper mails with subjects.

I don’t mean to overload you guys but I’m trying to provide as much useful feedback and possible.

> 
> 
>> 1) for..in doesn’t work with JSArray (see #4)
> 
> Report bug.

ok. 

This has to with a myriad of type casting problems between pascal strings/arrays that should be addressed. Already after a few dozen lines of code I’m getting trapped between using pascal or JS types. At the moment using Pascal types is nice because they’re familiar and type safe but they’re missing features that exist in the JS types and require frequent types casts if they work at all.

> 
>> 4) JSArray really needs to be a “toll free bridge” to Pascal arrays. 
>> 	- Any JS function that takes JSArray as an argument should accept Pascal dynamic arrays. JS would accept any array so why are we type casting from Pascal if we use array of xxx instead of JSArray?
>> 	- If we use JSArray then we need to cast for for..in to work right? That’s not very good obviously.
>> 	- Pascal dynamic arrays should probably have JSArray functions built-in since they are aliases for JSArrays anyways. It’s actually a feature of Pascal that we can do “array of integer” and get an error if we attempt to push a non-integer value to the array so we should take advantage of that.
> 
> There is no short answer.

See above. This should be properly addressed.

> 
> 
>> 5) should string and TJSString by toll free bridged also? I’m already having type casting problems using Pascal strings and passing to JS functions even though they are the same type internally. String concatenation between the types doesn’t seem to work either which doesn’t seem right.
> 
> typeof(new String()) === 'object’'

I don’t follow. Both “string” and TJString are the same type in the final output so they should be interchangeable. I can’t concatenate strings and numbers like JS can do. Is that a bug?

Already I had to make an overload of a function depending on what type I was using. I foresee this pattern being repeated over and over.

procedure Fatal (messageString: string); overload;
begin
	writeln('*** FATAL: ', messageString);
	exit;
end;

procedure Fatal (messageString: TJSString); overload;
begin
	writeln('*** FATAL: ', messageString);
	exit;

> 
>> 9) bytes is TJSUInt8Array but can’t be passed to a method expecting TJSBufferSource even though it’s a subclass of TJSBufferSource. Casting to TJSBufferSource doesn’t work either and gives nonsensical message.
>> 	gl.bufferData(gl.ARRAY_BUFFER, bytes, gl.STATIC_DRAW);
> 
> Report bug.

Ok. This actually one of may bugs with what appears to be basic polymorphism failing. I tried a number of different ways to pass this but in the end I had to add another method to the class which took a JSValue.

Regards,
	Ryan Joseph



More information about the Pas2js mailing list