[Pas2js] Records as pure data?

Ryan Joseph ryan at thealchemistguild.com
Wed May 9 14:38:42 CEST 2018



> On May 9, 2018, at 5:56 PM, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
> 
> No. JS objects are associative arrays. There is no first or second
> property. This is true for arrays as well. In JS v[0] is the same as
> v["0"].
> 
> If you want a two element Float32Array and access its 0 and 1 element
> as x and y, then maybe this could eventually be achieved with a class
> helper or an advanced record.

The record syntax is basically just a redundant class as it is now so it makes sense to do something else with it to make it more useful. 

Maybe records could return their contents as bytes using some JavaScript functions like Float32Array? The record below for example is an associative array of objects I understand but there could be Pascal syntax (or just a function like you suggested) which packs its fields into contiguous memory?

type
	TMyRec = record
		a: string;
		b: integer;
		c: boolean;
	end;

Honestly though this whole idea is probably just limited to WebGL because you probably don’t need to worry about bytes in common JS.


Regards,
	Ryan Joseph



More information about the Pas2js mailing list