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

max haughton maxhaton at gmail.com
Sat Feb 5 18:37:52 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.

It still saves typing + a projects coding standard may ban having 
the body on the same line within braces.

Typing is also not the only point of this example. The proposed 
syntax reduces the example to only the moving parts, not only 
saving typing but reducing visual noise on the screen.


More information about the Digitalmars-d mailing list