[fpc-devel] Publish some of FPC's internal cross-platform functionality

Anton Shepelev anton.txt at gmail.com
Thu Mar 14 21:05:35 CET 2019


I wrote:

> system.inc defines FileFunc as a procedure without a
> return value:
>
>    FileFunc = Procedure(var t : TextRec);
>
> whereas streamio.pp defines the same operations as
> functions returning longint, e.g.:
>
>    Function StreamRead(var F: TTextRec) : longint;

Here are the relevant fragments from the Turbo Pascal
Language Reference
(http://turbopascal.org/files/Turbo_Pascal_Version_7.0_Language_Guide_1992.pdf):

   The four functions that define each device driver are
   Open, InOut, Flush, and Close.  The function header of
   each function is:

      function DeviceFunc(var F: TTextRec): Integer;

   [...]  The return value of a device-interface function
   becomes the value returned by IOResult.  If the return
   value is zero, the operation was successful.

compare it with FreePascal's defintion:

   FileFunc = Procedure(var t : TextRec);

It is not withtout a reason that the type is called FileFunc
instead of FileProc, and both TurboPascal and Delphi analyse
the return value.

The document goes on:

   The Flush function is called at the end of each Read,
   Readln, Write, and Writeln.  It can optionally flush the
   text file buffer.

Whereas in FreePascal Flush is not called in read mode.

-- 
Please, do not forward replies to my e-mail.




More information about the fpc-devel mailing list