[fpc-pascal] Mode Delphi and functions as parameters.

Constantine Yannakopoulos alfasud.ti at gmail.com
Sat Mar 21 11:04:02 CET 2015

On Fri, Mar 20, 2015 at 11:55 AM, Michael Schnell <mschnell at lumino.de>

> what to to if a function has no parameter and returns a value that is a
> pointer to a function of exactly this type ?

​The logical thing for the compiler would be to assume that the programmer
meant that a reference should be passed​. If the programmer wanted to
invoke the function ans pass the result reference they should use empty
parentheses aka "the invocation operator":

CallFunction(SomeFunction); // passes a reference to SomeFunction.
CallFunction(SomeFunction()); // passes the result of the invocation of

​So no ambiguity, albeit a very subtle semantic difference that can easily
produce bugs.​ But IMHO the "@" notation isn't much better either.

PS: I tend to always use the "()" notation when invoking functions with no
arguments so it will be clear to a future reader that I'm invoking a
function and not assigning some variable. Makes a difference with poorly
named functions (not starting with a verb):

ADate := Date;
ADate := Date();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150321/12e2835e/attachment.html>

More information about the fpc-pascal mailing list