dfmt options

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Sun Mar 22 10:05:06 PDT 2015


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 .. $]; }

This currently expands to 20 lines of code.

bool empty()
{
    return arr.length == 0;
}

T opIndex(size_t i)
{
    return arr[idx];
}

T front()
{
    return arr[0];
}

void popFront()
{
    arr = arr[1 .. $];
}



More information about the Digitalmars-d mailing list