Compiler version: 05.2017
I am planning to rewrite parts of the Pascal runtime in Pascal and, as told before, I am working all the time doing extensions to the Pascal runtime, for example working with PDS members on MVS.
What makes things difficult:
the Pascal language defined files as typed files; the files differ by the types of their element. So for example it is not possible to write a function that works for a file of type TEXT (FILE OF CHAR) as well as for a file of type FILE OF INTEGER, even if the function doesn't do anything with respect to the content of the file - e.g. if the function does only ASSIGN file names or member names to the file.
The only solution to this problem until now was: the function had to be implemented by the compiler itself, and the compiler could be tolerant for all types of files.
But I wanted to be able to write such functions as ASSIGN in Pascal, in a library seperate from the compiler.
My solution is:
I added a new standard type ANYFILE to the compiler, much the same way as I added last year a new type VOIDPTR. The type ANYFILE is compatible to every other file type. But, because you cannot assign files using the assignment statement, the only thing you can do: you can call a procedure or function and pass a "normal" file argument to an ANYFILE var parameter. Inside the function, the (somehow) restricted actions on the ANYFILE variable may be executed - for example ASSIGN, or FILEFCB, which gives you access to the file's FCB.
This extension will be present in the next release of the Stanford Pascal compiler; and then the ASSIGN and ASSIGNMEM Procedures, which were limited to TEXT files until now, will be possible for all sorts of files.
BTW: ANYPTR is the new name for VOIDPTR; VOIDPTR will be kept for compatibility reasons. For both ANYPTR and ANYFILE, access to the elements (dereferencing) via the arrow operator is not allowed; this is now flagged by the compiler with two new error messages
187: DEREF NOT ALLOWED WITH ANYPTR TYPE;
188: ACCESS TO FILE BUFFER NOT ALLOWED WITH ANYFILE TYPE.
Here is a short example of a function using the new ANYFILE type:
|
this way, ASSIGNMEM is usable for every type of file.