Hmm.  That sort of seems like a mixin, in a hackish way, but you can
almost feel the strain of a statically-typed language being bent to
behave in this way.  Also, they mention this, which seems like a real
drawback if you want to write clean OO code:

"...Note though that you can't add methods to classes, pass them to
Java code, and expect the Java code to be able to call them. Since
most people use statically typed Java with little reflection I doubt
this case would come up much anyway."

Ruby mixins are much cleaner:  http://www.rubycentral.com/book/tut_modules.html

Contrast this with a Ruby mixin, in which the "include" keyword
results in a real live instance method that is identical to all the
other pre-existing instance methods:

module Foo
 def fooit(a)
   a + "foo"
 end
end

class Bar
 include Foo
end

p Bar.instance_methods.sort  # <- fooit is an instance method

p Bar.new.fooit('bar') # -> 'barfoo'




On 4/25/07, Warner Onstine <[EMAIL PROTECTED]> wrote:
I'm not that familiar with Ruby and mixins, but I believe that
Categories are the rough equivalent in Groovy.

http://docs.codehaus.org/display/GROOVY/Groovy+Categories
http://groovy.codehaus.org/Expandos,+Classes,+and+Categories

You'll have to look and let me know (but a quick web search *seems*
to validate this).

-warner

On Apr 25, 2007, at 6:34 PM, Chad Woolley wrote:

> I've heard Groovy doesn't do Mixins.  Is this true?  I think this
> makes it inferior to ruby (although I guess you could run AspectJ
> against Groovy bytecode, right?)
>
> On 4/25/07, William H. Mitchell
> <[EMAIL PROTECTED]> wrote:
>> I started out on a list of things to see if/how a new language has,
>> but I suppose I've ended up with more of a wish list:
>>
>>      Operator overloading, with arbitrary operators
>>      Support for functions as values
>>      Curried functions
>>      Anonymous functions
>>      Function composition
>>      Tuples
>>      Infinite-precision integers, with auto-transitioning
>>      Labeling of data structures via pattern matching
>>      Variable length argument lists
>>      Metadata support, like Java's annotations
>>      Run-time compilation of code
>>      Preprocessor, just like C
>>      Complete mutability--be able to augment/redefine integer
>> addition, for example
>>
>>      Implementation issues:
>>         A good debugger (I like TDD but hands off my debugger!  This
>> means you!)
>>         Fast compilation
>>         Ability to produce a standalone binary
>>
>> It's interesting to note that things like object-orientation, garbage
>> collection, and exception handling have become so common that I'd
>> mostly finished my list before they crossed my mind.
>>
>> Python does pretty well on the above list but for some reason I have
>> trouble getting excited about it.  For years I'd admired Python from
>> a distance but after spending an afternoon with it, I was left with a
>> ho-hum feeling.
>>
>> My experience with Ruby was the opposite from Python -- I didn't like
>> what I first saw with Ruby but the more I learned, the more I liked
>> it.  Now I love it!  I don't think that Ruby comes close to Icon's
>> elegance and cohesiveness but Ruby has largely replaced Icon in my
>> toolbox.  (We'll see if Ruby rules for 24 years, like Icon did, if I
>> live that long...)
>>
>> Now I'm reading through Groovy in Action.  I have to say that Groovy
>> looks pretty good so far.  Groovy's very close integration with Java
>> allows interesting mix-and-match with Java and a low hurdle for Java
>> programmers.  In some ways the Java/Groovy relationship is like
>> C/C++.  Lots of programmers (like me!) got interested in C++ because
>> it allowed them to move to OOP but still use C libraries.  Groovy
>> opens the door for dynamic typing and great expressiveness without
>> losing the investment in Java libraries.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Warner Onstine - Programmer/Author
New book! Tapestry 101 available at http://sourcebeat.com/books/
tapestrylive.html
[EMAIL PROTECTED]
http://warneronstine.com/blog




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to