digitalmars.D - std.string.split and std.regex.split conflict
- Andrea Fontana <advmail katamail.com> Sep 14 2011
- Dmitry Olshansky <dmitry.olsh gmail.com> Sep 14 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Sep 14 2011
- Dmitry Olshansky <dmitry.olsh gmail.com> Sep 14 2011
- Dmitry Olshansky <dmitry.olsh gmail.com> Sep 14 2011
- Christian Kamm <kamm-incasoftware removethis.de> Sep 14 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Sep 14 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Sep 14 2011
- Brad Anderson <eco gnuk.net> Sep 14 2011
dmd gives me this error: Error: std.string.split at /usr/include/d/dmd/phobos/std/string.d(70) conflicts with std.regex.split(String) at /usr/include/d/dmd/phobos/std/regex.d(2962) It seems there's a name-conflict on standard library. How can I solve it? I've tried with dmd 2.054 64bit and 2.056 64bit both compiled by myself on my ubuntu machine.
Sep 14 2011
On 14.09.2011 16:29, Andrea Fontana wrote:dmd gives me this error: Error: std.string.split at /usr/include/d/dmd/phobos/std/string.d(70) conflicts with std.regex.split(String) at /usr/include/d/dmd/phobos/std/regex.d(2962) It seems there's a name-conflict on standard library. How can I solve it?
For now you can solve it by using full name: std.regex.split or std.string.split or use selective imports on std.string to avoid split.I've tried with dmd 2.054 64bit and 2.056 64bit both compiled by myself on my ubuntu machine.
Yes, it's a bug, they should overload each other, it exists since std.regex inclusion maybe, I tried to fix this one in the past and failed. There is something about lookup rules I obviously don't get. -- Dmitry Olshansky
Sep 14 2011
On Wed, 14 Sep 2011 08:36:53 -0400, Dmitry Olshansky <dmitry.olsh gmail.com> wrote:On 14.09.2011 16:29, Andrea Fontana wrote:
I've tried with dmd 2.054 64bit and 2.056 64bit both compiled by myself on my ubuntu machine.
Yes, it's a bug, they should overload each other, it exists since std.regex inclusion maybe, I tried to fix this one in the past and failed. There is something about lookup rules I obviously don't get.
No, the overload rules are specific. Two modules cannot overload each other. Otherwise, adding an import can change calls. Please read this part of the spec: http://www.d-programming-language.org/function.html#overload-sets -Steve
Sep 14 2011
On 14.09.2011 16:58, Steven Schveighoffer wrote:On Wed, 14 Sep 2011 08:36:53 -0400, Dmitry Olshansky <dmitry.olsh gmail.com> wrote:On 14.09.2011 16:29, Andrea Fontana wrote:
I've tried with dmd 2.054 64bit and 2.056 64bit both compiled by myself on my ubuntu machine.
Yes, it's a bug, they should overload each other, it exists since std.regex inclusion maybe, I tried to fix this one in the past and failed. There is something about lookup rules I obviously don't get.
No, the overload rules are specific. Two modules cannot overload each other. Otherwise, adding an import can change calls. Please read this part of the spec: http://www.d-programming-language.org/function.html#overload-sets
Anti-hijacking? I knew it, but it's not applicable here. I mean these functions should not conflict because their argument types do not intersect. You can't mistake Regex for String, these checks are present in template constraints, is it not enough? -- Dmitry Olshansky
Sep 14 2011
Anti-hijacking? I knew it, but it's not applicable here. I mean these functions should not conflict because their argument types do not intersect. You can't mistake Regex for String, these checks are present in template constraints, is it not enough?
I think there is more to it. The algorithm to process overloading from multiple overload sets is quite complex, and one of the problems of C++. I can't remember the name of it, but D just avoids it by not allowing multiple overload sets.
It is allowed from the same doc, as long as not ambiguous: import A; import B; void bar(C c) { foo(); // calls A.foo() foo(1L); // calls A.foo(long) foo(c); // calls B.foo(C) foo(1,2); // error, does not match any foo foo(1); // error, matches A.foo(long) and B.foo(int) A.foo(1); // calls A.foo(long) } I'm implying that in case where one overload set contains no valid functions (constraints fail) the other should be used.In any case, it's not a bug, it's by design.
Not so sure, maybe bug in phobos then. -- Dmitry Olshansky
Sep 14 2011
Steven Schveighoffer wrote:I can't remember the name of it, but D just avoids it by not allowing multiple overload sets. In any case, it's not a bug, it's by design.
It's not by design. Multiple overload sets are okay, as long as there are no ambiguities, see Dmitry's example. The problem is that std.string uses selective imports: public import std.array : join, split and that selective imports are still broken. (#314) Test case: a.d: void foo() {} b.d: void foo(int) {} c.d: public import b : foo; use.d: import a; import b; // breaks if you import c instead void main() { foo(); foo(1); }
Sep 14 2011
On Wed, 14 Sep 2011 09:10:28 -0400, Dmitry Olshansky <dmitry.olsh gmail.com> wrote:On 14.09.2011 16:58, Steven Schveighoffer wrote:On Wed, 14 Sep 2011 08:36:53 -0400, Dmitry Olshansky <dmitry.olsh gmail.com> wrote:On 14.09.2011 16:29, Andrea Fontana wrote:
I've tried with dmd 2.054 64bit and 2.056 64bit both compiled by myself on my ubuntu machine.
Yes, it's a bug, they should overload each other, it exists since std.regex inclusion maybe, I tried to fix this one in the past and failed. There is something about lookup rules I obviously don't get.
No, the overload rules are specific. Two modules cannot overload each other. Otherwise, adding an import can change calls. Please read this part of the spec: http://www.d-programming-language.org/function.html#overload-sets
Anti-hijacking? I knew it, but it's not applicable here. I mean these functions should not conflict because their argument types do not intersect. You can't mistake Regex for String, these checks are present in template constraints, is it not enough?
I think there is more to it. The algorithm to process overloading from multiple overload sets is quite complex, and one of the problems of C++. I can't remember the name of it, but D just avoids it by not allowing multiple overload sets. In any case, it's not a bug, it's by design. -Steve
Sep 14 2011
On Wed, 14 Sep 2011 11:42:45 -0400, Christian Kamm <kamm-incasoftware removethis.de> wrote:Steven Schveighoffer wrote:I can't remember the name of it, but D just avoids it by not allowing multiple overload sets. In any case, it's not a bug, it's by design.
It's not by design. Multiple overload sets are okay, as long as there are no ambiguities, see Dmitry's example. The problem is that std.string uses selective imports: public import std.array : join, split and that selective imports are still broken. (#314) Test case: a.d: void foo() {} b.d: void foo(int) {} c.d: public import b : foo; use.d: import a; import b; // breaks if you import c instead void main() { foo(); foo(1); }
OK, my apologies for not understanding the problem properly (or apparently overload resolution!) Sorry, I think you are right, it is a bug! -Steve
Sep 14 2011
--00151747954ec36ce704ace95843 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Sep 14, 2011 at 6:29 AM, Andrea Fontana <advmail katamail.com>wrote:dmd gives me this error: Error: std.string.split at /usr/include/d/dmd/phobos/std/string.d(70) conflicts with std.regex.split(String) at /usr/include/d/dmd/phobos/std/regex.d(2962) It seems there's a name-conflict on standard library. How can I solve it?
Programming Language book. This should probably be added to the errata. I've tried with dmd 2.054 64bit and 2.056 64bit both compiled bymyself on my ubuntu machine.
Brad Anderson --00151747954ec36ce704ace95843 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Wed, Sep 14, 2011 at 6:29 AM, Andrea Fontana <span dir=3D"ltr"><<a hr= ef=3D"mailto:advmail katamail.com">advmail katamail.com</a>></span> wrot= e:<br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D= "margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> dmd gives me this error:<br> <br> Error: std.string.split at<br> /usr/include/d/dmd/phobos/std/string.d(70) conflicts with<br> std.regex.split(String) at<br> /usr/include/d/dmd/phobos/std/regex.d(2962)<br> <br> It seems there's a name-conflict on standard library. How can I<br> solve it?<br> <br></blockquote><div><br></div><div>I encountered this same name conflict = with an early code sample from The D Programming Language book.=A0This shou= ld probably be added to the errata.</div><div><br></div><blockquote class= =3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd= ing-left:1ex;"> I've tried with dmd 2.054 64bit and 2.056 64bit both compiled by<br> myself on my ubuntu machine.<br> <br> <br> <br> </blockquote></div><br><div>Regards,</div><div>Brad Anderson</div> --00151747954ec36ce704ace95843--
Sep 14 2011









Dmitry Olshansky <dmitry.olsh gmail.com> 