October 06, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@dawg.eu

--- Comment #10 from Martin Nowak <code@dawg.eu> ---
(In reply to Walter Bright from comment #5)
> Or, (2) can be accomplished by overloading isDir() to accept string
> arguments. But this implies adding an overload to every function that
> accepts an InputRange. This is out of the question.

What's the problem with that? It's rather good to precompile the common template instantiations into phobos.

--
October 06, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

--- Comment #11 from Martin Nowak <code@dawg.eu> ---
Slight variation of the bug where the aliased string is an lvalue, but cannot be assigned.

cat > bug.d << CODE
struct InternedString
{
    void opAssign(InternedString other)
    {
        this.data = other.data;
    }

    string data;
    alias data this;
}

auto bug(InternedString s)
{
    import std.file : exists;
    return exists(s);
}
CODE

This breaks b/c some code in utf.d tries to `r = r[1 .. $]` slice an InternedString.

--
October 07, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

--- Comment #12 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Martin Nowak from comment #10)
> (In reply to Walter Bright from comment #5)
> > Or, (2) can be accomplished by overloading isDir() to accept string
> > arguments. But this implies adding an overload to every function that
> > accepts an InputRange. This is out of the question.
> 
> What's the problem with that? It's rather good to precompile the common template instantiations into phobos.

The problem is that it pretty much doubles the number of functions in Phobos. And means that everyone who writes a reusable library has to have double functions.

--
October 07, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

--- Comment #13 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Rainer Schuetze from comment #8)
> It still fails, so instead of emitting an error message the compiler could change the type of the function arguments to the aliased type and retry deduction and constraint check. For multiple arguments with alias this, this could lead to a large number of possible combinations to try, though.

Given how overloading even now can lead to inexplicable seeming results, I view such an additional layer of complexity as a looming disaster, especially with the combinatorial aspect of it.

I have thought about something like:

    struct foo(T : isInputRange) { ... }

where the constraint would become part of the type deduction logic, but that's a major addition to the language, not something we can just throw in.

--
October 07, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

--- Comment #14 from Walter Bright <bugzilla@digitalmars.com> ---
Check this out:

https://github.com/D-Programming-Language/phobos/pull/3694

--
October 07, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

--- Comment #15 from Rainer Schuetze <r.sagitario@gmx.de> ---
>Check this out: https://github.com/D-Programming-Language/phobos/pull/3694

This is pretty much the workaround given by Kenji above. It has the downside that you have to copy the full DirEntry object to the stack as a function argument. Not a big issue for DirEntry, but it can be pretty bad if the struct has an expensive postblit or if it is disabled.

--
October 09, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

--- Comment #16 from Rainer Schuetze <r.sagitario@gmx.de> ---
Here is a version that overloads structs with alias this to a string range by reference, avoiding the copy problem:

auto isDir(Range)(Range input)
    if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range))
{
    //...
}

auto isDir(Range)(ref Range input)
    if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range))
        && is(StringTypeOf!Range))
{
    return isDir(cast(StringTypeOf!Range) input);
}

--
October 09, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

--- Comment #17 from Rainer Schuetze <r.sagitario@gmx.de> ---
>auto isDir(Range)(ref Range input)

"auto ref" seems to work even better.

--
October 14, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|cannot pass arguments of    |rangified functions no
                   |type DirEntry to std.file   |longer work with alias
                   |functions                   |this'ed strings (e.g.
                   |                            |DirEntry)

--
October 14, 2015
https://issues.dlang.org/show_bug.cgi?id=15027

--- Comment #18 from Martin Nowak <code@dawg.eu> ---
Lots of small PR fixups already, but we need to consistently check/fix all of
the rangified functions.
D-Programming-Language/phobos: Pull Request #3676
D-Programming-Language/phobos: Pull Request #3702
D-Programming-Language/phobos: Pull Request #3703
D-Programming-Language/phobos: Pull Request #3704

See the changelog for a list. http://dlang.org/changelog/2.068.0.html#rangified-functions http://dlang.org/changelog/2.069.0.html#more-rangified-functions

https://trello.com/c/W6JX23lD/113-issue-15027-rangified-functions-no-longer-work-with-alias-this-ed-strings-e-g-direntry

--