Thread overview
opDispatch with template parameter and property syntax doesn't work
Jan 12, 2010
Jacob Carlborg
Jan 12, 2010
Eldar Insafutdinov
January 12, 2010
The following doesn't work, is it a known issue or should I report it.

class C
{
	void opDispatch (string str, T) (T t) {}
}

class D
{
	void opDispatch (string str) (int t) {}
}

C c = new C;
c.foo = 3; // doesn't work
c.foo(3); // works

D d = new D;
d.foo = 3; // works
January 12, 2010
Jacob Carlborg Wrote:

> The following doesn't work, is it a known issue or should I report it.
> 
> class C
> {
> 	void opDispatch (string str, T) (T t) {}
> }
> 
> class D
> {
> 	void opDispatch (string str) (int t) {}
> }
> 
> C c = new C;
> c.foo = 3; // doesn't work
> c.foo(3); // works
> 
> D d = new D;
> d.foo = 3; // works

If you watched the presentation by Anders Hejlsberg which was posted here recently, they have different methods to implement for methods and property look up for their dynamic type system. I would not want to have them mixed. Maybe something like opProperty?
January 12, 2010
On Tue, 12 Jan 2010 14:04:44 -0500, Jacob Carlborg <doob@me.com> wrote:

> The following doesn't work, is it a known issue or should I report it.
>
> class C
> {
> 	void opDispatch (string str, T) (T t) {}
> }
>
> class D
> {
> 	void opDispatch (string str) (int t) {}
> }
>
> C c = new C;
> c.foo = 3; // doesn't work
> c.foo(3); // works
>
> D d = new D;
> d.foo = 3; // works

I would expect that in the future you must annotate your opDispatch with @property to get the correct behavior.

If at that point, C's opDispatch doesn't work like a property, I would report a bug.  The property behavior is very much in flux right now.  But I wouldn't expect IFTI to work on a property syntax like that unless the function is actually labeled with @property.

-Steve