<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Blaise--- via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am Mi., 16. Dez. 2020, 10:14:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> The modeswitch Result enables the use of Result as an alias for *any* routine …<br>
<br>
Incorrect. The identifier Result does not alias the routine, it aliases the routine's return value.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">For non operators the routine's name *is* the name of the return variable. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> … that returns a result no matter if an explicit result name is set or not.<br>
<br>
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).<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">For non operators the name of the real result value *is* the name of the routine and Result is the alias. Operators don't have names (in the classical sense, internally they have one of course), thus for the modes without Result modeswitch a way had to be introduced to specify the name of the variable containing the result. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Were the presented cases examined when the current behaviour was implemented? And, if so, what were the points defending it? Does anyone actually think that there is even one good theoretical or practical reason to reject the following?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">I doubt that was examined back then, but right now the behavior is consistent and I see no need to change it. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> Additionally the following will fail as well (this is allowed in mode Delphi however):<br>
> function Result: LongInt;<br>
<br>
That is not quite relevant for this discussion. A function and its return value are different entities.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Yes, it is relevant for this discussion, because it's the same piece of code in the compiler that handles this.</div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div></div>