Another idiom I wish were gone from phobos/druntime
Nick Treleaven via Digitalmars-d
digitalmars-d at puremagic.com
Thu Feb 5 05:13:09 PST 2015
On 05/02/2015 08:56, Kagamin wrote:
> On Thursday, 5 February 2015 at 01:34:49 UTC, deadalnix wrote:
>> On Thursday, 5 February 2015 at 01:07:56 UTC, Andrei Alexandrescu wrote:
>>> Would introduce an exception to our brace-on-its-line rule.
>>>
>>
>> Will I start the next world war if I mention this rule is only useful
>> to eat vertical space on my screen (especially when using contracts) ?
>
> If contracts would support single statements:
+1, but with the statements in the function body please:
auto opSlice(size_t low, size_t high)
{
in assert(low <= high);
in assert(0 == 0);
out(r) assert(r.length == high - low);
out(r) assert(!r.empty);
import std.range : take;
return this[low .. $].take(high - low);
}
I think that reads better. For ease of implementation inline contracts
could be required to come before any runtime variables/code.
More information about the Digitalmars-d
mailing list