[fpc-devel] Explicitly named return values and implicit aliases Result

Michael Van Canneyt michael at freepascal.org
Wed Dec 16 10:24:39 CET 2020

On Wed, 16 Dec 2020, Blaise--- via fpc-devel wrote:

> On 16.12.2020 0:07, Sven Barth wrote:
>> No, those two are in fact correct this way.
> Is that the /team's/ consensus?
>> The modeswitch Result enables the use of Result as an alias for *any* 
> routine …
> Incorrect. The identifier Result does not alias the routine, it aliases the 
> routine's return value.
>> … that returns a result no matter if an explicit result name is set or not.
> I maintain that such approach is an orthogonality violation. In light that 
> FPC provides a syntax for explicitly naming the return value, the consistent 
> and conceptually simplest way to treat Result as the implicit/default name 
> for that value, not as an alias to a name that cannot even be specified in 
> most cases (non-operators).

To be correct: Result is not the name of the result value, it is an alias.

The following shows this:

Function MyResult : String;


You can still use the function name for the result, so "Result" is in fact an
alias for the function name, which is the actual name for the result value.

But I do agree with your point that it should be allowed to explicitly name 
Result as Result for operators, even when the Result identifier is allowed.

It really makes no sense to me to forbid this.


More information about the fpc-devel mailing list