[Nitro] class_extension

transfire at gmail.com transfire at gmail.com
Tue Mar 20 09:50:01 EDT 2007



On Mar 20, 8:48 am, "George Moschovitis"
<george.moschovi... at gmail.com> wrote:
> > Moreover, do you understand the technical
> > differences between the two? Do you realize that the first does not
> > extend past the first inclusion? Ie. include Foo above into Bar and
> > then Bar into Baz, Baz would not have the module methods --for that
> > you'd have to add even more crufty code.
>
> Hmm, I didn't know about that. I thought (and othere agree) that the
> standard idiom is more readable. But if your code works better (and
> safer) as you describe, I guess we should reconsider, and keep using
> this. Thanks for clearing this out.

No problem. Sorry for coming on so strong, but this really shocked me.
But I understand that most people don't know about the many
discussions on this topic. Matz is considering class_extension, or
something like it, for inclusion in Ruby 1.9/2.0. But he's not 100%
sure yet. So there's still room for improvement if anyone can think of
a better way.

I also understand it is not idiomatic 1.8 Ruby. Unfortunately what has
become idiomatic is the ClassMethods hack made popular by Hal Fulton
in the Ruby Way. Ara T. Howard goes even further and creates an
InstanceMethods module! Lol. :)

In any case. I am deeply involved in this particular development as I
am a strong proponent of allowing module singleton methods to be mixed-
in. Personally I would prefer an alternate method to #include that
does it automatically. But for whatever reason Matz seems hesitant of
this.

Maybe this alternative would be better however, as it appears more
idiomatic?


  module Foo

    class << extension

    end

  end


I might suggest that to Matz. How does that strike you?

T.



More information about the Nitro-general mailing list