[fpc-devel] Syntax problem with function result

Jeppe Johansen jepjoh2 at kom.aau.dk
Tue Jul 27 20:32:44 CEST 2010


I wouldn't miss not having the name of the function as a result variable 
in mode objfpc, at all. I think it would be a valid addition, as a 
compiler directive that was turned on as default, as not to break 
existing code

Hans-Peter Diettrich skrev:
> I just had to chase an strange bug, in a local (nested) subroutine. 
> When I made several functions (if_statement() ...) local subroutines 
> of method statement(), they stopped to work properly :-(
>
> After many tries I concluded, that every (recursive) invocation of the 
> "statement" method was replaced by the "statement" result.
>
> While it is possible to replace all occurences of "statement" by 
> "statement()", it is not clear whether this is really the intended 
> purpose of every occurence of "statement". This uncertainty prevents 
> any automated refactoring of old style function code.
>
> IMO we should have at least an option, that a function name can *not* 
> be used for the function result any more, for the result we have the 
> Result variable. Then we can safely distinguish between function calls 
> (by function name) and results (by "Result"). If ever required, local 
> functions still can refer to the result of some enclusing function, by 
> e.g. qualified <function_name>.Result.
>
> DoDi
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel




More information about the fpc-devel mailing list