Hello all,

I'm currently defining some external classes for my JSON data payload
which contains some array elements.

So far I got two solutions:

The first one uses "pascal arrays". This gives a lot of type safety but
there are no array helpers yet which make requires me to use the pascal
way of manipulating the array.

Tmyarraytype = array of TJSObject;
tmyclass = class external name 'abc' (TJSObject)
property myarray: Tmyarraytype read fmyarray;
end;

However there is TJSArray class which contains a lot of usefull methods
which are available on all JavaScript arrays. Thus the second solution is:

tmyclass = class external name 'abc' (TJSObject)
property myarray: TJSArray read fmyarray;
end;

Then I have all the methods but no type safety at all and I need to do
typecast for each array access.

I think this would be an ideal case for using generics. Are there any
plans to implement TJSArray as generic as soon as generics are supported
by pas2js?

Regards
Simon Ameis

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to