March 2009


Ruby: Extending class definitions with modules

David Carney, 31 March 2009

This took me a little while to track down, but (thanks to Nathan Weizenbaum at Unspace), I’ve got the canonical solution for extending a class’ methods (not its instance methods) with a module:

module Foo
  def self.included(base)
    base.extend ClassMethods
  end

  module ClassMethods
    def foo
      puts "Foo!"
    end
  end
end

module Bar
  include Foo
end
 

After that, one can safely call Bar.foo

EASTL and problem solving

Peter McCurdy, 27 March 2009

I have no conceivable use for the thing, but I still very much enjoyed reading about EASTL, Electronic Arts’ STL reimplementation. I guess I just like reading about people sensibly analyzing an existing solution, finding its problems, coming up with fixes, and having their lives get better. Especially when the fixes involve solving performance problems without doing anything disgusting.