Breaking ";" rule with lambda functions

pascal111 judas.the.messiah.111 at gmail.com
Mon Aug 1 14:52:03 UTC 2022


On Monday, 1 August 2022 at 14:46:33 UTC, ag0aep6g wrote:
> On Monday, 1 August 2022 at 14:39:17 UTC, pascal111 wrote:
>> On Monday, 1 August 2022 at 14:34:45 UTC, ag0aep6g wrote:
> [...]
>>> `a => a > 0` is not a statement. It's an expression.
>>
>> But it is still a "function", and functions make statements!! 
>> It's not a normal expression.
>
> It's a normal expression.
>
> `foo => bar` is an expression that doesn't involve any 
> statement. So there's no semicolon.
>
> `(foo) { return bar; }` does contain a return statement. As you 
> expect, there's a semicolon. But it's still an expression like 
> any other.

If `foo => bar` == `(foo) { return bar; }`, then  `foo => bar` is 
a function. "=>" is not an operator, it's a special symbol for 
lambda "function".

If A == B, so A's types is the same of B's type. How can it be 
withstanding `foo => bar` == `foo => bar` == `(foo) { return bar; 
}` and `foo => bar` is an expression and the other is a 
function?!! no sense.


More information about the Digitalmars-d-learn mailing list