I agree 100% that startsWith needs to work with immutable(X[]).  Nonetheless, the proper way to address this is by fixing the language, not by relying on expedient bugs.  I insisted on fixing this because history has shown that if too many people start relying on behavior that is clearly a bug but happens to be expedient, the bug becomes politically unfixable no matter how wrong the behavior is.  Fixing the rest of Phobos such that startsWith() and similar functions will work with immutable(X[]) without relying on Bug 3534 would have been a monumental task (I tried). <br>
<br>My proposal for dealing with this issue has always been that IFTI should instantiate a function with an Unqual!(T) when passed a T, if and only if the given T is implicitly convertible to Unqual!(T).  For example:<br>
<br><span style="font-family: courier new,monospace;">void foo(T)(T arg) {}  </span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">immutable str = "A family of foxes found food in the forest.";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">foo(str);  // Equivalent to foo!(immutable(char)[])(str);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">immutable num = 2;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">foo(num);  // Equivalent to foo!(int)(num);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">const myRetro = retro([1,2,3,4,5,6]);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">foo(myRetro);  // const(Retro!(int[])) doesn't implicitly convert to<br>               // Unqual!(const(Retro!(int[]))).</span>  No Unqual applied.<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">             </span><br><br><div class="gmail_quote">On Wed, Oct 27, 2010 at 5:25 PM, Sönke Ludwig <span dir="ltr"><<a href="mailto:ludwig@informatik.uni-luebeck.de">ludwig@informatik.uni-luebeck.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

  
    
  
  <div bgcolor="#ffffff" text="#000000">
    Hm.. while it makes sense that technically an immutable(X[]) is not
    an input range for the mentioned reason, practically it does not
    make sense not to allow such arrays in functions like startsWith.
    Apart from the obscure range related cause, there is no obvious
    reason why this should be the case. For any non-expert D user I
    would expect this to be very confusing and annoying for the rest. So
    well, for me looking from the outside, this still looks like a
    regression although technically it maybe is not.<br>
    <br>
    Am 27.10.2010 22:58, schrieb David Simcha:
    <div><div></div><div class="h5"><blockquote type="cite">This is not a regression.  The example code you posted
      was never supposed to work, but relied on bugs in DMD to work
      nonetheless.  An immutable(char[]) is not an input range since you
      can't call popFront() on it.  You used to be able to because of
      Bug 3534 (<a href="http://d.puremagic.com/issues/show_bug.cgi?id=3534" target="_blank">http://d.puremagic.com/issues/show_bug.cgi?id=3534</a>). 
      I added code to Phobos to explicitly disable this, so that until
      3534 gets fixed people avoid writing code that relies on it.<br>
      <br>
      <div class="gmail_quote">On Wed, Oct 27, 2010 at 3:47 PM, Sönke
        Ludwig <span dir="ltr"><<a href="mailto:ludwig@informatik.uni-luebeck.de" target="_blank">ludwig@informatik.uni-luebeck.de</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
           There seems to be a regression in std.algorithm.startsWith.
          With 2.049 this still worked:<br>
          <br>
          invariant string s = "Hello, World!";<br>
          bool res = s.startsWith("Hello");<br>
          <br>
          now the template cannot be matched anymore. Remove the
          invariant and it works.<br>
          <br>
          Am 27.10.2010 21:13, schrieb Walter Bright:
          <div>
            <div><br>
              <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
                Fix is uploaded.<br>
                <br>
                Don Clugston wrote:<br>
                <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
                  On 27 October 2010 16:50, Stephan Dilly <<a href="mailto:Dilly@funatics.de" target="_blank">Dilly@funatics.de</a>>
                  wrote:<br>
                  <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
                    On 27.10.2010 16:14, Don Clugston wrote:<br>
                    <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
                      On 27 October 2010 15:29, Stephan Dilly<<a href="mailto:Dilly@funatics.de" target="_blank">Dilly@funatics.de</a>>
                       wrote:<br>
                      <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
                        On 27.10.2010 14:51, Stephan Dilly wrote:<br>
                        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
                          <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
                            <a href="http://ftp.digitalmars.com/dmd1beta.zip" target="_blank">http://ftp.digitalmars.com/dmd1beta.zip</a><br>
                            <a href="http://ftp.digitalmars.com/dmd2beta.zip" target="_blank">http://ftp.digitalmars.com/dmd2beta.zip</a><br>
                          </blockquote>
                          1) the client still says it is version 2.049<br>
                          <br>
                          2) there seems to be a regression with pure
                          opCall methods introduced.<br>
                          The<br>
                          following code used to build with dmd2049 but
                          now does not:<br>
                          <br>
                          <br>
                          struct Foo<br>
                          {<br>
                            static Foo opCall(in Foo _f) pure<br>
                            {<br>
                                return Foo;<br>
                            }<br>
                          }<br>
                          <br>
                          instead the compiler issues the following
                          error:<br>
                          "Error: struct bug.Foo no size yet for forward
                          reference"<br>
                          <br>
                          the workaround would be to remove the pure but
                          that is no option for my<br>
                          codebase full of pure opCalls.<br>
                          <br>
                          <br>
                          regards,<br>
                            Stephan<br>
                        </blockquote>
                        Ok to be fair, this is the correct code that
                        works in dmd2049 and does<br>
                        not<br>
                        in the beta:<br>
                        <br>
                        struct Foo<br>
                        {<br>
                          static Foo opCall(in Foo _f) pure<br>
                          {<br>
                              return _f;<br>
                          }<br>
                        }<br>
                      </blockquote>
                      That is happening because in mtype.c, line 5013,
                      it's trying to work<br>
                      out which form of purity the function is. It can't
                      do this for a<br>
                      struct, until it knows if the struct has any
                      pointer members. This is<br>
                      a problem if it's a member function.<br>
                      I don't know if it really needs to determine
                      purity level so early on.<br>
                      _______________________________________________<br>
                      dmd-beta mailing list<br>
                      <a href="mailto:dmd-beta@puremagic.com" target="_blank">dmd-beta@puremagic.com</a><br>
                      <a href="http://lists.puremagic.com/mailman/listinfo/dmd-beta" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a><br>
                      <br>
                    </blockquote>
                    I don't know either ;)<br>
                    Does that mean that static pure opCalls wont be
                    possible from now on ?<br>
                  </blockquote>
                  <br>
                  Your code should continue to work. It's a regression.<br>
                  <br>
                </blockquote>
                _______________________________________________<br>
                dmd-beta mailing list<br>
                <a href="mailto:dmd-beta@puremagic.com" target="_blank">dmd-beta@puremagic.com</a><br>
                <a href="http://lists.puremagic.com/mailman/listinfo/dmd-beta" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a><br>
              </blockquote>
              <br>
              _______________________________________________<br>
              dmd-beta mailing list<br>
              <a href="mailto:dmd-beta@puremagic.com" target="_blank">dmd-beta@puremagic.com</a><br>
              <a href="http://lists.puremagic.com/mailman/listinfo/dmd-beta" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a><br>
            </div>
          </div>
        </blockquote>
      </div>
      <br>
      <pre><fieldset></fieldset>
_______________________________________________
dmd-beta mailing list
<a href="mailto:dmd-beta@puremagic.com" target="_blank">dmd-beta@puremagic.com</a>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-beta" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a></pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
dmd-beta mailing list<br>
<a href="mailto:dmd-beta@puremagic.com">dmd-beta@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-beta" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a><br></blockquote></div><br>