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

Blaise at blaise.ru Blaise at blaise.ru
Wed Dec 16 12:25:50 CET 2020


On 16.12.2020 12:24, Michael Van Canneyt via fpc-devel wrote:
> To be correct: Result is not the name of the result value, it is an alias.

I did not dispute that. The important point here is: "an alias" to /what/?

> You can still use the function name for the result, so "Result" is in fact an alias for the function name

Result is not "an alias for the function name" because you cannot use Result to refer to the function:
-------8<-------
function Foo: Integer;
var X: function : Integer;
begin
	Result(); // ERROR
	X := Result; // ERROR
end;
-------8<-------

> the function name, which is the actual name for the result value.

I can get behind this notion; however, within the function, that name is overloaded. Thus, we should not say, like Sven did, that Result aliases the function (name); we should say, like I did, that it aliases the return value (name).

But, conceptually, I would rather look at the function name resolving to the return value as a backward-compatible alias, and say that Result is the true (default) name for the return value. Such notion fits modern usage.

> 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.

The score thus far: 1:1.

-- 
βþ


More information about the fpc-devel mailing list