Better docs for D (WIP)
Adam D. Ruppe via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Sat Jan 30 13:32:12 PST 2016
On Saturday, 30 January 2016 at 21:22:02 UTC, Chris Wright wrote:
> You probably know about this, but some of the source code
> formatting is a
> little off (and allowing javascript / cross-site requests
> doesn't help).
Right, the contract formatter is something I started a while ago
but not finished yet.
And actually, a lot of the contracts are ugly anyway, even if
nicely formatted (that is, the code is more
implementation-focused than presentable as documentation), so I'm
not sure trying to print them is actually a good idea.
This is the original source of your picture:
in
{
static if (hasLength!Range)
{
// TODO: core.checkedint supports mixed signedness yet?
import core.checkedint : adds, addu;
import std.conv : ConvException, to;
alias LengthType = typeof(range.length);
bool overflow;
static if(isSigned!Enumerator && isSigned!LengthType)
auto result = adds(start, range.length, overflow);
else static if(isSigned!Enumerator)
{
Largest!(Enumerator, Signed!LengthType) signedLength;
try signedLength =
to!(typeof(signedLength))(range.length);
catch(ConvException)
overflow = true;
catch(Exception)
assert(false);
auto result = adds(start, signedLength, overflow);
}
else
{
static if(isSigned!LengthType)
assert(range.length >= 0);
auto result = addu(start, range.length, overflow);
}
assert(!overflow && result <= Enumerator.max);
}
}
It is certainly nicer when correctly formatted... but still, what
is that actually saying?
> The initial part is more readable than the original source
> code, but the in contract is a bit messy.
aye, that's where I spent all the time.
> Even with that, this is a lot easier and more approachable than
> the dlang.org docs. Thanks!
awesome
More information about the Digitalmars-d-announce
mailing list