Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
January 05, 2013 [Issue 9272] New: opDispatch conflicts with UFCS on template functions | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9272 Summary: opDispatch conflicts with UFCS on template functions Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: dransic@gmail.com --- Comment #0 from Nicolas Sicard <dransic@gmail.com> 2013-01-05 04:57:36 PST --- struct Foo { void opDispatch(string s)() {} } void bar(T)(Foo f) {} unittest { Foo foo; bar!int(foo); // OK foo.bar!int(); // Error: foo.opDispatch isn't a template } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 05, 2013 [Issue 9272] opDispatch conflicts with UFCS on template functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicolas Sicard | http://d.puremagic.com/issues/show_bug.cgi?id=9272 Nils <nilsbossung@googlemail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |nilsbossung@googlemail.com Resolution| |INVALID --- Comment #1 from Nils <nilsbossung@googlemail.com> 2013-01-05 06:33:55 PST --- No bug here, I think. opDispatch takes precedence and just fails to compile. The same thing happens with --- struct Foo { void bar() {} } --- The error message could be improved though. foo.opDispatch is a template. It's foo.opDispatch!"bar" that is not. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 05, 2013 [Issue 9272] opDispatch conflicts with UFCS on template functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicolas Sicard | http://d.puremagic.com/issues/show_bug.cgi?id=9272 --- Comment #2 from Nicolas Sicard <dransic@gmail.com> 2013-01-05 09:05:00 PST --- (In reply to comment #1) > opDispatch takes precedence and just fails to compile. Obviously. But is it really by design? This works, where opDispatch does not take precedence: --- struct Foo { void opDispatch(string s)() {} } void baz(Foo f) {} unittest { Foo foo; foo.baz(); // OK } --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 05, 2013 [Issue 9272] opDispatch conflicts with UFCS on template functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicolas Sicard | http://d.puremagic.com/issues/show_bug.cgi?id=9272 --- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-01-05 09:12:16 PST --- (In reply to comment #2) > (In reply to comment #1) > > opDispatch takes precedence and just fails to compile. > > Obviously. But is it really by design? > > This works, where opDispatch does not take precedence: > --- > struct Foo { > void opDispatch(string s)() {} > } > > void baz(Foo f) {} > > unittest { > Foo foo; > foo.baz(); // OK > } > --- Just *template* opDispach is required for operator overloading. Therefore non-template function is simply ignored. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 05, 2013 [Issue 9272] opDispatch conflicts with UFCS on template functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicolas Sicard | http://d.puremagic.com/issues/show_bug.cgi?id=9272 --- Comment #4 from Nicolas Sicard <dransic@gmail.com> 2013-01-05 09:17:39 PST --- (In reply to comment #3) > (In reply to comment #2) > > (In reply to comment #1) > > > opDispatch takes precedence and just fails to compile. > > > > Obviously. But is it really by design? > > > > This works, where opDispatch does not take precedence: > > --- > > struct Foo { > > void opDispatch(string s)() {} > > } > > > > void baz(Foo f) {} > > > > unittest { > > Foo foo; > > foo.baz(); // OK > > } > > --- > > Just *template* opDispach is required for operator overloading. Therefore non-template function is simply ignored. Yes. I understand why it doen't work at the moment. I just found it inconsistent. Maybe this should be an enhancement request then... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 05, 2013 [Issue 9272] opDispatch conflicts with UFCS on template functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicolas Sicard | http://d.puremagic.com/issues/show_bug.cgi?id=9272 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simen.kjaras@gmail.com --- Comment #5 from Simen Kjaeraas <simen.kjaras@gmail.com> 2013-01-05 12:19:17 PST --- (In reply to comment #2) > This works, where opDispatch does not take precedence: > --- > struct Foo { > void opDispatch(string s)() {} > } > > void baz(Foo f) {} > > unittest { > Foo foo; > foo.baz(); // OK > } Except, of course, opDispatch *does* take precedence here. Try this instead: import std.stdio : writeln; struct Foo { void opDispatch(string s)() { writeln("opDispatch: ", s); } } void baz(Foo f) { writeln("function: baz"); } void main( ) { Foo foo; foo.baz(); // OK } I can assure you it prints opDispatch: baz. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 06, 2013 [Issue 9272] opDispatch conflicts with UFCS on template functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicolas Sicard | http://d.puremagic.com/issues/show_bug.cgi?id=9272 --- Comment #6 from Nicolas Sicard <dransic@gmail.com> 2013-01-06 04:49:57 PST --- (In reply to comment #5) > (In reply to comment #2) > > This works, where opDispatch does not take precedence: > > --- > > struct Foo { > > void opDispatch(string s)() {} > > } > > > > void baz(Foo f) {} > > > > unittest { > > Foo foo; > > foo.baz(); // OK > > } > > Except, of course, opDispatch *does* take precedence here. Try this instead: > > import std.stdio : writeln; > > struct Foo { > void opDispatch(string s)() { writeln("opDispatch: ", s); } > } > > void baz(Foo f) { writeln("function: baz"); } > > void main( ) { > Foo foo; > foo.baz(); // OK > } > > I can assure you it prints opDispatch: baz. Ah! I was trapped by the minimalism of my example. OK thanks. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation