[fpc-pascal] Mode Delphi and functions as parameters.
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>
>> 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();
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
Compilers should not assume. Programmers should be explicit about what they
Assumptions based on ambiguous semantics are an unending source of problems.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal