| From | Sent On | Attachments |
|---|---|---|
| Paulo Gabriel Poiati | Jul 10, 2010 4:07 pm | .diff |
| Paul King | Jul 11, 2010 3:36 pm | |
| Guillaume Laforge | Jul 12, 2010 1:54 am | |
| Erik Pragt | Jul 12, 2010 2:28 am | |
| Dierk König | Jul 12, 2010 2:31 am | |
| Guillaume Laforge | Jul 12, 2010 2:33 am | |
| Martin C. Martin | Jul 12, 2010 6:35 am | |
| Paulo Gabriel Poiati | Jul 12, 2010 8:20 am | |
| Hamlet D'Arcy | Jul 12, 2010 11:43 pm | |
| Alex Tkachman | Jul 12, 2010 11:49 pm | |
| Hamlet D'Arcy | Jul 14, 2010 1:46 am |
| Subject: | Re: [groovy-dev] What about a @Mutable ast transformation (with implementation) | |
|---|---|---|
| From: | Hamlet D'Arcy (haml...@gmail.com) | |
| Date: | Jul 14, 2010 1:46:34 am | |
| List: | org.codehaus.groovy.dev | |
In fact, I think it should be both Cloneable and Externalizable.
There are so many edge cases to writing a properly Cloneable object. I doubt a good implementation could be made. Something could be made for classes with all simple data types, but that doesn't get you very far. Suspect the same thing for Externalizable.
I could be wrong, of course.
-- Hamlet D'Arcy haml...@gmail.com
On Tue, Jul 13, 2010 at 8:49 AM, Alex Tkachman <alex...@gmail.com> wrote:
Canonicat is nice. In fact, I think it should be both Cloneable and Externalizable.
On Tue, Jul 13, 2010 at 9:43 AM, Hamlet D'Arcy <haml...@gmail.com> wrote:
@Canonical seems like a very good name given the contents of the Bill Venners article Dierk referenced. Ours doesn't do Serializable and Clonable, but I think the intent is the same. I think it's good that Canonical is not already a commonly used term.
-- Hamlet D'Arcy haml...@gmail.com
On Mon, Jul 12, 2010 at 5:21 PM, Paulo Gabriel Poiati <paul...@gmail.com> wrote:
Tks for the feedback. I agree, @Mutable only makes sense in the context of an existing @Immutable counterpart. And not everyone in groovy is familiar with @Immutable. Personally, i don't like @Data here (same reasons of Martin). @Canonical is cool, but it's not a common term. @Struct is simple and make a lot of sense. []'s Paulo Poiati
blog.paulopoiati.com
On Mon, Jul 12, 2010 at 10:35 AM, Martin C. Martin <mar...@martincmartin.com> wrote:
@Struct or @Structure ? People with C/C++ will have strong associations for those. And even for those who don't, it seems appropriate.
Best, Martin
On 7/12/2010 4:55 AM, Guillaume Laforge wrote:
Great work, Paulo.
I think the name @Mutable is a bit misleading. Paul was referring to a JIRA issue where we were mentioning @Identity or @Data. @Data sounds perhaps a bit too much like providing data fixtures for a test framework, but @Identity conveys the idea it's about expressing the "identity" of the bean, how it represents itself (toString()), how it compares/identifies itself (equals()/hashCode). So I think @Identity sounds better.
Anyone else can think of a better name?
Guillaume
On Mon, Jul 12, 2010 at 00:36, Paul King <pau...@asert.com.au <mailto:pau...@asert.com.au>> wrote:
Hi Paulo, looks cool!
I added a reference to your post to the relevant issue: http://jira.codehaus.org/browse/GROOVY-2879
Thanks for the patch.
On 11/07/2010 9:08 AM, Paulo Gabriel Poiati wrote:
Hello, I think it's a good idea to have an ast transformation that create the toString, equals, hashCode and positional args constructor (like @Immutable does). Also, because it's mutable it can have untyped properties and not all properties need to be initialized in the constructor.
I was searching for something like that, and I found this:
http://archive.codehaus.org/lists/org.codehaus.groovy.user/msg/1aae...@mail.gmail.com
Paulo King suggested the @Mutable ast.
I did an implementation, based in the current groovy trunk (rev 20439). Most of the work was stole from Paul King @Immutable implementation).
What differs from @Immutable: - It's mutable, implying that nor properties or class are final, and it provide setters methods. - Allow untyped properties. - Objects are passed by reference in the constructor, not wrapped or cloned. - Hashcode is not cached. - Constructor arguments are optional. - If a class is annotated as @Mutable and @Immutable an exception is throw. - Inheritance is possible
The patch is attached...
Example:
*@Mutable class Customer {* * String first, last* * int age* * Date since* * Collection favItems = ['Food']* * def object * *}* * * *def d = new Date()* *def anyObject = new Object()* *def c1 = new Customer(first:'Tom', last:'Jones', age:21, since:d, favItems:['Books', 'Games'], object: anyObject)* *def c2 = new Customer('Tom', 'Jones', 21, d, ['Books', 'Games'], anyObject) * *assert c1 == c2* * * * * *def c3 = new Customer(last: 'Jones', age: 21)* *def c4 = new Customer('Tom', 'Jones')* *assert null == c3.since* *assert 0 == c4.age* *assert c3.favItems == ['Food'] && c4.favItems == ['Food']*
I will appreciate any kind of feedback.
Tks !
[]'s Paulo Poiati
blog.paulopoiati.com <http://blog.paulopoiati.com> <http://blog.paulopoiati.com>
--------------------------------------------------------------------- To unsubscribe from this list, please visit:
--------------------------------------------------------------------- To unsubscribe from this list, please visit:
-- Guillaume Laforge Groovy Project Manager Head of Groovy Development at SpringSource http://www.springsource.com/g2one
--------------------------------------------------------------------- To unsubscribe from this list, please visit:
--------------------------------------------------------------------- To unsubscribe from this list, please visit:
--------------------------------------------------------------------- To unsubscribe from this list, please visit:
--------------------------------------------------------------------- To unsubscribe from this list, please visit:






.diff