On 21 March 2015 at 10:04, Constantine Yannakopoulos <alfasud...@gmail.com> wrote:
> On Fri, Mar 20, 2015 at 11:55 AM, Michael Schnell <mschn...@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@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > Compilers should not assume. Programmers should be explicit about what they want. Assumptions based on ambiguous semantics are an unending source of problems. -- Frank Church ======================= http://devblog.brahmancreations.com
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal