Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
November 14, 2013 function XXXX conflict with YYYY | ||||
---|---|---|---|---|
| ||||
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? |
November 14, 2013 Re: function XXXX conflict with YYYY | ||||
---|---|---|---|---|
| ||||
Posted in reply to Agustin | 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.
|
November 14, 2013 Re: function XXXX conflict with YYYY | ||||
---|---|---|---|---|
| ||||
Posted in reply to Agustin | 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
|
November 14, 2013 Re: function XXXX conflict with YYYY | ||||
---|---|---|---|---|
| ||||
Posted in reply to Agustin | 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));
}
|
November 14, 2013 Re: function XXXX conflict with YYYY | ||||
---|---|---|---|---|
| ||||
Posted in reply to evilrat | 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? |
November 14, 2013 Re: function XXXX conflict with YYYY | ||||
---|---|---|---|---|
| ||||
Posted in reply to Agustin | 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. |
November 14, 2013 Re: function XXXX conflict with YYYY | ||||
---|---|---|---|---|
| ||||
Posted in reply to evilrat | 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.
|
November 14, 2013 Re: function XXXX conflict with YYYY | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | 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 |
November 14, 2013 Re: function XXXX conflict with YYYY | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | 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. |
Copyright © 1999-2021 by the D Language Foundation