opDispatch with template parameter and property syntax doesn't work

Steven Schveighoffer schveiguy at yahoo.com
Tue Jan 12 13:46:22 PST 2010


On Tue, 12 Jan 2010 14:04:44 -0500, Jacob Carlborg <doob at 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



More information about the Digitalmars-d mailing list