Discussion Thread: DIP 1043--Shortened Method Syntax--Community Review Round 1
bauss
jj_1337 at live.dk
Wed Feb 9 11:02:03 UTC 2022
On Wednesday, 9 February 2022 at 10:34:57 UTC, Max Samukha wrote:
>
> I disagree. The proposed feature makes D overall more
> consistent.
Yes it does, but not if both cases aren't supported.
And you shouldn't return the value from a setter, it should be
void.
Which looks better?
```
int value() => _value;
void value(int newValue) => _value = newValue;
```
Or
```
int value() => _value;
void value(int newValue) { _value = newValue; }
```
The first case definitely looks better IMHO.
And yeah as you said void could just be int, but it shouldn't.
The setter should be void.
It is almost universally accepted that setters should __never__
return anything and there's only one case where you might return
from a setter and that is in fluid programming where you return
the parent object to allow chaining.
So it's irrelevant that it works as a work-around.
More information about the Digitalmars-d
mailing list