Hi!

Would it be of interest to expose hash value generation through the
use of rb_hash_start(), rb_hash_uint(), and rb_hash_end() in a new
object called, for example, Hash::Value?

This could be implemented (imagining that C is a module containing
simple wrappers around said functions) as

class Hash::Value
  def initialize(object)
    @value = C.rb_hash_start(object.class.hash)
  end

  def <<(object)
    @value = C.rb_hash_uint(@value, object.hash)
    self
  end

  def hash
    C.rb_hash_end(@value)
  end
end

Users could then define #hash in a standard way:

class A
  def initialize(a, b, c)
    @a, @b, @c = a, b, c
  end

  def ==(other)
    self.class == other.class and
      a == other.a and
      b == other. b and
      c == other.c
  end

  alias eql? ==

  def hash
    (Hash::Value.new(self) << a << b << c).hash
  end

  protected

  attr_reader :a, :b, :c
end