www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - function XXXX conflict with YYYY

reply "Agustin" <agustin.l.alvarez hotmail.com> writes:
final uint registerEvent(T, J)(IPlugin, void delegate(J))
{
  ....
}

final uint registerEvent(IPlugin, EventHandler, EventInfo, ulong)
{
  ....
}

There seems to be a problem when having two function with same 
name but different parameters. Only happend when one of the 
function use templates. Is that a compiler limitation?
Nov 14 2013
next sibling parent reply "evilrat" <evilrat666 gmail.com> writes:
On Thursday, 14 November 2013 at 16:27:39 UTC, Agustin wrote:
 final uint registerEvent(T, J)(IPlugin, void delegate(J))
 {
  ....
 }

 final uint registerEvent(IPlugin, EventHandler, EventInfo, 
 ulong)
 {
  ....
 }

 There seems to be a problem when having two function with same 
 name but different parameters. Only happend when one of the 
 function use templates. Is that a compiler limitation?
this is by design. templates are generic so they can take anything(by default), this way shadowing specialized functions which is more suitable for certain types.
Nov 14 2013
parent reply "evilrat" <evilrat666 gmail.com> writes:
mmm.. this is strange because for simple types it works fine(i'm 
using dmd 2.064.2). can you show reduced example of this?
Nov 14 2013
parent "Gary Willoughby" <dev nomad.so> writes:
On Thursday, 14 November 2013 at 16:59:25 UTC, evilrat wrote:
 mmm.. this is strange because for simple types it works 
 fine(i'm using dmd 2.064.2). can you show reduced example of 
 this?
See bearophile's answer.
Nov 14 2013
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Agustin:

 final uint registerEvent(T, J)(IPlugin, void delegate(J))
 {
  ....
 }

 final uint registerEvent(IPlugin, EventHandler, EventInfo, 
 ulong)
 {
  ....
 }

 There seems to be a problem when having two function with same 
 name but different parameters. Only happend when one of the 
 function use templates. Is that a compiler limitation?
Have you tried an updated DMD compiler? I think this was recently fixed. Bye, bearophile
Nov 14 2013
prev sibling next sibling parent "Gary Willoughby" <dev nomad.so> writes:
On Thursday, 14 November 2013 at 16:27:39 UTC, Agustin wrote:
 final uint registerEvent(T, J)(IPlugin, void delegate(J))
 {
  ....
 }

 final uint registerEvent(IPlugin, EventHandler, EventInfo, 
 ulong)
 {
  ....
 }

 There seems to be a problem when having two function with same 
 name but different parameters. Only happend when one of the 
 function use templates. Is that a compiler limitation?
This works fine with v2.064.2 import std.stdio; class ClassName { final uint registerEvent(T, J)(T x, void delegate(J)) { return 1; } final uint registerEvent(long, string, int, ulong) { return 1; } } void main(string[] args) { auto x = new ClassName(); writefln("%s", x.registerEvent!(int, int)(1, delegate(int x) {})); writefln("%s", x.registerEvent(1, "sdsds", 3, 4)); }
Nov 14 2013
prev sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Nov 14, 2013 at 05:27:38PM +0100, Agustin wrote:
 final uint registerEvent(T, J)(IPlugin, void delegate(J))
 {
  ....
 }
 
 final uint registerEvent(IPlugin, EventHandler, EventInfo, ulong)
 {
  ....
 }
 
 There seems to be a problem when having two function with same name
 but different parameters. Only happend when one of the function use
 templates. Is that a compiler limitation?
On older compilers, you can work around this limitation by adding empty compile-time parameters to the second function: final uint registerEvent()(IPlugin, EventHandler, EventInfo, ulong) { ... }
From what I heard, this limitation has been removed in the latest
compiler. T -- It only takes one twig to burn down a forest.
Nov 14 2013
parent reply "Gary Willoughby" <dev nomad.so> writes:
On Thursday, 14 November 2013 at 17:13:18 UTC, H. S. Teoh wrote:
 It only takes one twig to burn down a forest.
http://www.youtube.com/watch?v=d-S1o5OmMMo
Nov 14 2013
parent "Agustin" <agustin.l.alvarez hotmail.com> writes:
Thanks, i updated to v2.064.2 and everything works just fine. I 
had this issue long time ago and it was annoying to have multiple 
function with different names.
Nov 14 2013