digitalmars.D - std.string.split and std.regex.split conflict
- Andrea Fontana (9/9) Sep 14 2011 dmd gives me this error:
- Dmitry Olshansky (9/18) Sep 14 2011 For now you can solve it by using full name:
- Steven Schveighoffer (7/16) Sep 14 2011 No, the overload rules are specific. Two modules cannot overload each
- Dmitry Olshansky (7/23) Sep 14 2011 Anti-hijacking? I knew it, but it's not applicable here.
- Steven Schveighoffer (8/35) Sep 14 2011 I think there is more to it. The algorithm to process overloading from ...
- Dmitry Olshansky (15/24) Sep 14 2011 It is allowed from the same doc, as long as not ambiguous:
- Christian Kamm (17/21) Sep 14 2011 It's not by design. Multiple overload sets are okay, as long as there ar...
- Steven Schveighoffer (6/28) Sep 14 2011 OK, my apologies for not understanding the problem properly (or apparent...
- Brad Anderson (6/14) Sep 14 2011 I encountered this same name conflict with an early code sample from The...
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: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 -SteveI'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.
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: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 OlshanskyOn 14.09.2011 16:29, Andrea Fontana wrote: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-setsI'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.
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: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. -SteveOn Wed, 14 Sep 2011 08:36:53 -0400, Dmitry Olshansky <dmitry.olsh gmail.com> wrote: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?On 14.09.2011 16:29, Andrea Fontana wrote: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-setsI'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.
Sep 14 2011
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.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.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 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 11:42:45 -0400, Christian Kamm <kamm-incasoftware removethis.de> wrote:Steven Schveighoffer wrote:OK, my apologies for not understanding the problem properly (or apparently overload resolution!) Sorry, I think you are right, it is a bug! -SteveI 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 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, 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?I encountered this same name conflict with an early code sample from The D 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.Regards, Brad Anderson
Sep 14 2011