Hi,

I believe that there are issues in the way the Array
Class deals with self-referential arrays. (I became
aware of these issues by going throw the ArrayMixin
implementation.)

The set operations &, | hang with self-referential
arrays. My guess is that the implementation is based
on &= and |= (these operation hang to) and dup of self
- if this is so then the problem could be solved by
doing it the other way around - i.e. implementing
&=, |= in terms of &, |.

The #flatten! algorithm rejects simple non self-referential
arrays - z =[]; nonref = [1,z,z]; nonref.flatten! bombs.

The #flatten! algorithm happily flattens pretty convoluted
self-referential arrays like
ruby -e 'x = [1];y = ["a",x]; z=[2]; x << [[x,y]]; \
y << [[z,x]]; z<< [x]; p x.flatten! '
[1, "a",2]

There are fairly obvious algorithms to #flatten(!) any
array - basically untangle the ``array graph'' (not
unique for true self-referential arrays but there are
a couple of candidates sticking out) and flatten the
resulting ``array tree├˛.  A generalized #flatten(!)
method would have fairly descend properties (``convexity'')
but there are problem with threads and such a generalized
method is probably of questionable practical value
(there was little thread on this on the ruby-dev list
 a year ago - for example [ruby-dev:9017]).
On the other hand #flatten(!) should not reject simple
non self-referential arrays like ``nonref'' IMHO.

Christoph