Could you provide test case please. It will help to fix :)
>
> Shrug, it comes with the territory of using unreleased code :) I linked the
> mailing list post, so if people read it, they'll know this... but
> regardless, i like it. Also, mixins classes can only contain one method
> right? I ran into a lovely erm, StackOverFlow when i added more than one
> method to my mixin class..
>
>
> Alex Tkachman wrote:
> Thank you, Rob. But please be aware that it is experimental feature
> and can be reverted from trunk in any moment or seriously modifed.
> I mean it is a bit too early to popularize it :)
>
> On Wed, Apr 9, 2008 at 12:01 PM, Robert O'Connor <
rob@...> wrote:
>
>
> Alex, good job! I played with your mixin syntax in an unsavory way,
> overloaded the subtraction operator to add the two integers:
>
http://robbyoconnor.blogspot.com/2008/04/new-groovy-mixins-syntax.html>
> Again, good job!
> -rob
> Alex Tkachman wrote:
>
> See comments below
>
> On Wed, Apr 9, 2008 at 11:36 AM, Dierk König <
dierk.koenig@...> wrote:
>
>
>
> cool ;-)
>
> Thanks a lot for the implementation and the comprehensive
> description!
>
>
> | So what is mixin?
> |
> | Mixin is usual category-like class, which provides methods to
> | extend some (or several) existing classes.
> |
> | class ArrayListExt {
> | static def newArrayListMethod (ArrayList self) {
> | "result of newArrayListMethod "
> | }
> | }
>
> ... except that categories can be used to define
> methods on a combination of classes that work together
> to fulfill a common purpose. E.g.
> defining something like
>
> class IntCodec {
> static String encode (Integer self) { ... }
> static Integer decode (String self) { ... }
> }
>
> is not possible with mixins, since they only affect
> one class at a time.
>
> Right?
>
>
> In this case you will need to apply mixin separately to String and Integer.
>
> Initially I had syntax DefaultGroovyMethods.mixin IntCodec but as
> Jochen noticed in thread on global categories it brings a bit too much
> danger, so right now this functionality is banned. But it is very easy
> to return it back :)
>
>
>
> Also, categories have a scope of use. Mixins don't,
> right?
>
>
> Right, mixins has no scope.
>
>
>
> Is there also any difference in the affected threads?
> (I vaguely remember this has been discussed on the
> list before... sorry)
>
>
>
> No threading involved. Another difference from categories.
>
>
>
> | simple use of it
> |
> | ArrayList.mixin ArrayListExt
>
> how about setting the scope like
>
> ArrayList.mixin (ArrayListExt) {
> // new methods available here
> }
> // but not here anymore
>
>
>
> Assuming that ArrayListExt effects ArrayList (and hierarchy) only it
> is equivalent to using category.
>
>
>
> ?
>
> | @Mixin(MyClassExt)
> | class MyClass {
> | def result () {
> | longRunningJavaMethod ()
> | }
> | }
> |
> | and write for example in Java
> |
> | public MyClassExt {
> | public static Set<Collection> longRunningJavaMethod (MyClass
> | self) { /// }
> | }
>
> so cool and very powerful ;-)
>
> reminds me on my old Ruby days...
>
>
>
> | Another nice feature for groovy objects is ability to do per
> | instance mixins
>
> dito
>
>
> | 1) Methods of the class and super classes (including all
> | their modifications except categories)
> | 2) DGM methods
> | 3)
> | 4) EMC methods
> | 5) methods of categories in use
>
> well explained!
>
> Now how about this:
>
> class A { def foo() {'A'} }
> class B extends A { def foo() {'B'} } // subclass overrides method
>
> class M { static void foo(A self) {'M'} } // mixin redefines method
>
> A.mixin M
>
> println( new B().foo() )
>
> ???? %-)
>
>
> In theory expected behaviour is to print 'B' because B defines more
> specific method. But new B().super.foo () (not legal syntax of course)
> should print 'M' In practice, test case needed :)
>
>
>
> cheers
> Dierk
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>
http://xircles.codehaus.org/manage_email>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>
http://xircles.codehaus.org/manage_email>
>
>
>
>
>