Discussion Thread: DIP 1043--Shortened Method Syntax--Community Review Round 1

Doigt labog at outlook.com
Tue Feb 8 17:03:25 UTC 2022


On Tuesday, 8 February 2022 at 09:31:04 UTC, Max Samukha wrote:
> On Saturday, 5 February 2022 at 16:19:42 UTC, Doigt wrote:
>
>> Except commonly, and to take two popular examples: JavaScript 
>> and C#, the arrow notation is not understood to be a shorthand 
>> for a return expression but just an expression.
>
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/lambda-expressions#expression-lambdas:
>
> "An expression lambda *returns* the result of the expression..."
>
>> I don't think I'll use this new feature if I can't make my 
>> code base consistent in style. It makes no sense to me to have 
>> things like
>> int myFunc (int a) => something;
>> void myProc (int a) { something; }
>
> The former is equivalent to int myFunc (int a) { return 
> something; }. The latter - void myProc (int a) { something; 
> return; }.
>
>> it looks bad and it makes it seems like void is a special case 
>> that is not immediately obvious why the arrow notation is not 
>> used.

You cannot use MSDN as a source to counteract my argument because 
I mentioned "commonly" in reference to popular usage. You'd need 
a statistic to address that argument. But even ignoring that, if 
you take a few moments to lower your eyes, you'll see exactly 
that they also have a case for lambda expressions with no return 
values. This is actually fatal to you because you could've argued 
semantics and moved the goal post smoothly without me noticing. 
But semantics aside, it is clear to me and any one who is 
intellectually honest that what Microsoft refers to "statement 
expression" is the simple no return expression I was talking 
about earlier. Also you never addressed the JS side of my 
argument. You'll notice that documentation you linked has several 
types of arrow notations which links back to my point about them 
that there is not just one use for them.


More information about the Digitalmars-d mailing list