syntax sugar: std.path::buildPath instead of from!"std.path".buildPath
Seb via Digitalmars-d
digitalmars-d at puremagic.com
Wed Feb 15 09:18:15 PST 2017
On Wednesday, 15 February 2017 at 17:10:26 UTC, Adam D. Ruppe
wrote:
> On Wednesday, 15 February 2017 at 07:56:00 UTC, Jacob Carlborg
> wrote:
>> Your documentation is an improvement but it doesn't help when
>> reading the source code.
>
> Yeah, I think there's a few things we can do in the source too.
> We should find the common combinations and abstract them out,
> like I said before, isInputRangeOf is potentially useful.
>
> Though, like Andrei, I'm skeptical on doing too much of that,
> since the combinations can quickly explode and then you just
> have to search through more to figure out wtf they mean.
>
> That'd help the source and docs if we find the right balance.
Speaking of right balance, there's currently a PR at Phobos that
is a good candidate to get a common measure on how this balance
should be set:
https://github.com/dlang/phobos/pull/5132
The open question here is that for nearly every function in
std.file & std.path the constraint block looks like this:
uint getAttributes(R)(R name)
if (isInputRange!R && !isInfinite!R &&
isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R);
Now as this same block is used > 30x in Phobos one could argue
that it makes sense to use a convenience trait like:
enum isSomeInputRangeChar(R) = isInputRange!R && !isInfinite!R &&
isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R
which would obviously lead to:
uint getAttributes(R)(R name)
if (isSomeInputRangeChar!R)
What's your opinion on such a case?
More information about the Digitalmars-d
mailing list