vtereshkov / xdpw

XD Pascal: A small embeddable self-hosting Pascal compiler for Windows. Supports Go-style methods and interfaces
BSD 2-Clause "Simplified" License
274 stars 32 forks source link

Add ISO 7185 support #17

Open electric-socket opened 3 years ago

electric-socket commented 3 years ago

Hi, my name is Paul.

I think it would be nice if XDPW was ISO 7185 (Standard Pascal) compliant. In the Github repository tangentstorm / pascal in the directory P5 is the file pcom.pas which is a(n old) Pascal compiler from 1974 that was co-written by Nicklaus Worth himself. It generates instructions for the fictional Pascal-P machine (an early predecessor to Java's JavaVM virtual machine). It is also self-hosting, compiles perfectly with FPC or with itself, but on XDPW it faults on line 1 because it has file parameters in the &&Program statement, which was allowed then and is allowed under ISO 7185. These parameters are usually ignored, but can be used as file names for input or output files (a relic of the CDC mainframe Pascal was invented on. This program, or its companion PINT.PAS** use no advanced features like objects or even strings and would be a good testbed to use to check compatibility with the standard.

Thank you very much for your attention.

Paul Robinson paul@paul-robinson.us "The lessons of history teach us - if they teach us anything - that no one learns the lessons that history teaches us."

Mazdaywik commented 3 years ago

Niklaus Wirth, not Worth 😉.

vtereshkov commented 3 years ago

Hi Paul. Unfortunately, I no longer maintain the project. But it's even more important that I always considered ISO 7185 a stillborn standard. I think the language it defines is hardly usable, since it lacks units, open arrays, type casts, break/continue/exit, named goto labels - but at the same time requires strict declaration order and has to support input/output pseudo-files, inter-procedural goto's, "dereferencing" file variables and other archaic or even dangerous features.

All these issues were clearly summarized by Brian Kernighan. I think everyone understood them well even in the 1980s. Borland extended Pascal to turn it into a completely different, incompatible but much more versatile Turbo Pascal, Wirth designed Modula-2, and even the ISO committee tried to fix the language and issued ISO 10206 (which was out of touch with the "natural" language development - and thus again stillborn).