dfmt options

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Mar 22 10:15:22 PDT 2015


On 3/22/15 10:05 AM, Martin Nowak wrote:
> On 03/15/2015 12:15 AM, Brian Schott wrote:
>> What am I missing?
>
> Sorry haven't read the whole thread.
> I think there should be an option (even default on) to allow small
> single line functions.
>
> This can sometimes be fairly annoying. For example when writing range
> adapters, see
> https://github.com/D-Programming-Language/phobos/blob/77152b537b4cc6482d6181c17866475f1115beb9/std/range/package.d#L216.
>
> bool empty() { return arr.length == 0; }
> T opIndex(size_t i) { return arr[idx]; }
> T front() { return arr[0]; }
> void popFront() { arr = arr[1 .. $]; }

Agreed. Also, a thought: a mixin sounds like a nice way to generate such 
boilerplate if frequent. -- Andrei



More information about the Digitalmars-d mailing list