[fpc-devel] Procedural types returning file types

Sven Barth pascaldragon at googlemail.com
Fri Dec 18 14:06:16 CET 2020


Tomas Hajny via fpc-devel <fpc-devel at lists.freepascal.org> schrieb am Fr.,
18. Dez. 2020, 11:38:

> On 2020-12-18 10:01, Blaise--- via fpc-devel wrote:
>
>
> Hello,
>
> > The patch http://hg.blaise.ru/public/fpc/rev/698389953e49 (attached)
> > fixes the following:
> > -------8<-------
> > // EXPECTED: 'Error: Illegal function result type'
> > // ACTUAL: gets compiled
> > type M = function : file;
> >
> > begin
> > end.
> > -------8<-------
>
> Sorry for a silly question, but conceptually - why a file (which is
> technically a record) shouldn't be allowed if records are allowed and
> the result (i.e. the file) may be assigned to another variable of the
> type file? Do you have any information why the compiled functionality
> wouldn't work correctly?
>

Because TP and Delphi don't allow it either. In fact FPC doesn't allow it
as well for function declarations, but for function and method variables a
different code path is used.

Sidenote: it also isn't allowed to pass file type parameters by value (the
compiler checks this) which is why you always see them with "var" or
"const".

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20201218/1b663106/attachment.htm>


More information about the fpc-devel mailing list