[Rosettacode] D code line length limit
H. S. Teoh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu May 8 08:04:58 PDT 2014
On Thu, May 08, 2014 at 02:50:54PM +0000, bearophile via Digitalmars-d-learn wrote:
> H. S. Teoh:
>
> >FWIW, for very long function signatures I write it this way:
> >
> > const(T)[] myVeryLongFunction(T)(const(T)[] arr,
> > int x,
> > int y,
> > int z,
> > ExtraArgs extraArgs)
> > pure @safe nothrow
> > if (is(T : int) &&
> > someOtherLongCriteria!T &&
> > yetMoreVeryLongCriteria!T)
> > {
> > ...
> > }
>
> You also need the pre&post-conditions :-)
[...]
I actually had them in my first draft. :)
const(T)[] myVeryLongFunction(T)(const(T)[] arr,
int x,
int y,
int z,
ExtraArgs extraArgs)
pure @safe nothrow
if (is(T : int) &&
someOtherLongCriteria!T &&
yetMoreVeryLongCriteria!T)
in {
assert(x >= 0 && x < 5);
assert(y >= 0 && y < 5);
assert(z >= 0 && z < 5);
}
out(result)
{
assert(result[0] >= 0 && result[0] < 5);
assert(result[1] >= 1 && result[1] < 6);
assert(result[2] >= 2 && result[2] < 7);
}
body
{
...
}
There. :)
T
--
You are only young once, but you can stay immature indefinitely. -- azephrahel
More information about the Digitalmars-d-learn
mailing list