[Pas2js] First impressions and Queries
C Western
l at c-m-w.me.uk
Wed Jan 24 22:58:04 CET 2018
I would like to echo what others have said, that pas2js gives a very
workable implementation of Pascal in a web browser, and I have managed
to use it surprisingly easily on some non-trivial code. A couple of
queries/rough edges, (which I was able to work around):
1. The .map files produced always seem to be corrupt - they always begin:
)]}
{"version":3,"file":"ar.js","sources":["/home....
which doesn't look right. Am I doing something wrong? Fortunately the
code produced is sufficiently close to the original that debugging with
the firefox developer tools was straightforward.
2. An inline directive on a procedure gives an error - can't this simply
be ignored?
3. Adding a package as a requirement is slightly odd in lazarus - on
compiling the program, it first compiles the changed package file in
fpc, then with pas2js. This is harmless, but it can be confusing to sort
out error messages.
4. Char(65) fails (but Chr(65) is OK).
5. This may be an implementation choice, but SetLength on arrays is not
forcing a copy where fpc normally would; for example:
var
a, b: array of Integer;
begin
SetLength(a,1);
a[0] := 6;
b := a;
WriteLn(a[0], ' ', b[0]);
SetLength(a,1);
WriteLn(a[0], ' ', b[0]);
a[0] := 2;
WriteLn(a[0], ' ', b[0]);
gives with FPC:
6 6
6 6
2 6
but with pas2js:
6 6
6 6
2 2
These are minor gripes - I must say again that I am impressed how
straightforward it was.
Colin
More information about the Pas2js
mailing list