Feedback Thread: DIP 1043--Shortened Method Syntax--Community Review Round 1
Andre Pany
andre at s-e-a-p.de
Fri Feb 4 17:00:22 UTC 2022
On Friday, 4 February 2022 at 15:59:54 UTC, RazvanN wrote:
> On Friday, 4 February 2022 at 10:57:17 UTC, Mike Parker wrote:
>> [...]
>
> On Friday, 4 February 2022 at 10:57:17 UTC, Mike Parker wrote:
>
> In the code snippet in the rationale section the line "T from,
> to;" is not indented properly (I assume it is not intentional).
> Also, I think that the rationale sample is a bit manipulative,
> implying that the new feature helps you save lines, however, it
> is omitting of the fact that for function bodies that are
> comprised of a single return statement you can just put the
> body on the same line with the definition:
>
> ```d
> struct LongerExclusiveRange(T)
> {
> T from, to;
> invariant(from <= to);
> bool empty() { return from == to; }
> void popFront() { ++from; }
> T front() { return from; }
> }
>
> I think that the mentioned code sample does not represent a
> valid argument and should be dropped from the DIP.
In my opinion it is a valid argument. Actually you can write your
whole application in a single line;)
Just my opinion of beauty code: Braces should be used with line
breaks.
For single line function bodies the new syntax looks most
beautiful.
Kind regards
Andre
More information about the Digitalmars-d
mailing list