Discussion Thread: DIP 1043--Shortened Method Syntax--Final Review

Paul Backus snarwin at gmail.com
Wed Jun 15 13:40:20 UTC 2022


On Wednesday, 15 June 2022 at 09:35:37 UTC, bauss wrote:
> I'm still under the belief that it shouldn't just be 
> `AssignExpression`, because you should be able to use it to 
> call another function that has no return type.
>
> Ex.
>
> ```d
> void a(int x, int y) { ... }
>
> void b(int x) => a(x, 100);
> ```

This already works--both for the new syntax, and for the existing 
arrow-lambda syntax, and even for functions with an explicit 
`return` statement:

```d
void a(int x, int y) { /* ... */ }
void b(int x) => a(x, 100);
void function(int) c = x => a(x, 100);
void d(int x) { return a(x, 100); }
```

There is no need to specify this in the DIP because it is already 
documented in the language spec, under the description of 
`return` statements:

> An Expression of type void is allowed if the function specifies 
> a void return type. The Expression will be evaluated, but 
> nothing will be returned.

https://dlang.org/spec/statement.html#return-statement


More information about the Digitalmars-d mailing list