Hi,

2009/8/3 Tanaka Akira <akr / fsij.org>:
> In article <67e307490908012245x3bf3be81oc7f060c2569ad4ab / mail.gmail.com>,
> =A0Run Paint Run Run <runrun / runpaint.org> writes:
>
>>> * several real applications are found
>>
>> This change broke a lot of specs which was how I noticed it. For
>
> I don't count RubySpec as a real application.


I found one example that seems to be practical and considerable.

The following program implements a graph with adjacency list by
using Array and Struct:

  Node =3D Struct.new(:item, :neighbors)
  node1 =3D Node.new(1, [])
  node2 =3D Node.new(2, [node1])
  node1.neighbors << node2

Then consider a function of depth first search with Hash:

  def dfs(node, visited =3D {}, &block)
    return if visited[node]
    yield(node)
    visited[node] =3D true
    node.neighbors.each {|n| dfs(n, visited, &block) }
  end

  dfs(node1) {|n| p n.item }

This function worked on 1.8.7 and 1.9.1p243, but not on trunk.

If hash of recursive structure were a constant, this function
would work.  Collisions, however, would be terribly frequent.


I wonder that it might be intrinsically unreasonable to use
primitive data types for such a purpose.

--=20
Yusuke ENDOH <mame / tsg.ne.jp>