15 messages in org.codehaus.groovy.userRe: [groovy-user] Setter overloading ...
FromSent OnAttachments
Marc PalmerJun 4, 2008 7:08 am 
Jochen TheodorouJun 4, 2008 9:01 am 
Luke DaleyJun 4, 2008 3:44 pm 
Marc PalmerJun 5, 2008 2:57 am 
Jochen TheodorouJun 5, 2008 3:32 am 
Jochen TheodorouJun 5, 2008 3:43 am 
Luke DaleyJun 5, 2008 4:51 pm 
Danno FerrinJun 5, 2008 6:24 pm 
Jochen TheodorouJun 5, 2008 7:12 pm 
Luke DaleyJun 5, 2008 7:52 pm 
Luke DaleyJun 5, 2008 8:48 pm 
Michael S. JessopJun 5, 2008 9:49 pm 
Jochen TheodorouJun 6, 2008 4:03 am 
Danno FerrinJun 6, 2008 5:25 am 
Danno FerrinJun 6, 2008 5:28 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [groovy-user] Setter overloading - should it work?Actions...
From:Jochen Theodorou (blac@gmx.org)
Date:Jun 5, 2008 3:43:41 am
List:org.codehaus.groovy.user

[...]

The fact that groovy turns x.duration = y into x.setDuration(y) for me means that Groovy should definitely use normal method resolution.

well, that is wrong. Groovy does not simply turn it into a method call. It might result in that method call, but there is a major difference between these. First Groovy asks for that property in the MetaClass, and in this case a property is returned, which means its setter method is called. that means that normally no Groovy standard method call would happen here. Allowing overloaded setters currently means, that we have to do a full method selection each time the property is called. Additionally the information stored in the MetaProperty becomes simply wrong then, because it contains only one method, not both. Maybe you don't remember that by changing the information in the MetaProperty you can turn x.duration =y into x.foo(y).... meaning you could have a setter of any name... and not only that, you can even change the object, that is used to make the call on. While I think the last is not supported by the bean spec, I think the usage of other methods as setter (or getter) is supported by providing a bean info class.

Groovy goes much further than the bean spec already by providing this implicit property access.

I am puzzled... I mean... isn't the bean spec exactly about this?

It violates the principle of least surprise when you are coding with a Groovy head on. If you are coding with your Java beans oriented head on, it wouldn't seem like a problem.

properties are not method calls. They are different in definition and their path in the MOP is different. With my Java beans oriented head on I still see it like a problem, because the classes used to access the beans don't expect such things from you and may select a random setter.

If it's something that just doesn't work now please say so so a ticket can be raised.

I agree - is this technically feasible, if so can we JIRA it for 2.0?

for 2.0, yes.. only the ability to use exactly one setter for a property might be lost with this.

bye blackdrag