I spent some time over the weekend looking into FPC trunk's Pascal-to-JavaScript converter. Here are some notes I worked up about what I discovered:
https://macpgmr.github.io/MacXPlatform/PascalToJavaScript_AReport.html
Some clever and interesting stuff in the converter. Worth poking around in.
Actually, the mappings are in the test suite for fppas2js and comes up with *way* better code than you found.
(It is also the only test that currently seems to fail, but I found that is because of the assumption for the test is currently wrong: it should map to 'E', not 'G')
Furthermore note that * a lot of work * is currently being done in trunk by several people. Getting better all the time..
Also note the pas2js
utility is currently broken and should be considered dead code (disabled in make) . I filed a bug against it.
Worth poking around in.
Indeed..... especially if you use trunk and see al the updates flying about... Or are interested in source to source compilers or webassembly, asm.js and the likes..
[edit]
at 4.: was it "write once, compile anywhere" or "write once, document mañana"?
It is simply not finished. (or polished, to satisfy my Polish friends)
at 5.: relevance is in a) type safety b) using current knowledge.