[Pas2js] Records as pure data?

Ryan Joseph ryan at thealchemistguild.com
Thu May 10 04:52:30 CEST 2018



> On May 9, 2018, at 10:18 PM, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
> 
> On Wed, 9 May 2018 21:21:42 +0700
> Ryan Joseph <ryan at thealchemistguild.com> wrote:
> 
>> [...]
>> Then what happens with stuff like this? Not sure how to append arrays (didn’t like push for some reason)
> 
> Pascal arrays don't have "push".
> You can typecast to TJSArray. For example TJSArray(verts).push(v); .
> Eventually when pas2js gets array helpers you can add such things more
> easily.

Those should be included for certain. There’s no reason to use “array of xxx” syntax if can’t use push etc… I don’t even use them in FPC because they lack  simple array features that every other language has. Dynamic arrays really should be a "toll-free bridge” to JSArray but with types for safety. Otherwise just use JSArray always.
> 
> 
>> I know I can just give up and do everything with arrays of floats but it’s worth trying to figure out a better way to do this in advance instead of wasting time down the road trying to construct confusing arrays.
> 
> Here are some more ideas:

Thanks. The trunk version appears to be a subclass of an array which is probably the way to go. I built from pas2js from the SVN sources but I got a syntax error. Is that not the trunk version?

You could just add a constructor in there then couldn’t you?

type
 TJSFloat32Point = class external name 'Float32Array' (TJSFloat32Array)
 public
   x: Float32; external name '[0]';
   y: Float32; external name '[1]’;
 end;


Regards,
	Ryan Joseph



More information about the Pas2js mailing list