steven@mcvax.uucp (Steven Pemberton) (08/04/86)
In article <5918@lanl.ARPA> crs@lanl.UUCP writes: > (I realize that the lack of "separate compilation" in Pascal > precludes use of precompiled libraries of functions.) This question arises every now and then. But, there is nothing about Pascal that precludes separate compilation: just because some implementations demand extra syntax to handle it does not mean that that extra syntax is necessary. I have used a compiler (for Algol 68 as it happens but the idea is the same) that handled separate compilation without external declarations, includes or the like. It worked as follows (translated into Unix-like terms): Your separately compiled procedures looked like this: (it also allowed separately compiled constants, types and variables) program whatever(...etc...); function mysqrt(x: real): real; begin ...etc... end; function mysin(x: real): real; begin ...etc... end; begin (*Empty main program, though it didn't have to be: you could initialise variables here*) end. You then compiled this with the equivalent of pc -c mylib.p, and this produced mylib.a. Your program then looked like this: program p(...etc...); (*more procedures if you want*) begin writeln(mysqrt(4.0)) end. and you compiled this with pc mylib.a prog.p. The compiler picked up all type information from the .a file, and so strong typing was still done. It always struck me as a well thought out method. Steven Pemberton, CWI, Amsterdam; steven@mcvax.uucp