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

vfclists . vfclists at gmail.com
Sun Mar 22 00:00:07 CET 2015

On 21 March 2015 at 10:04, Constantine Yannakopoulos <alfasud.ti at gmail.com>

> On Fri, Mar 20, 2015 at 11:55 AM, Michael Schnell <mschnell at lumino.de>
> wrote:
>> 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
> SomeFunction.
> ​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();
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Compilers should not assume. Programmers should be explicit about what they
Assumptions based on ambiguous semantics are an unending source of problems.

Frank Church

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150321/75ad772c/attachment.html>

More information about the fpc-pascal mailing list