SystemStackError comparing self-referential structures

irb(main):021:0> a = []; a << a
=> [[…]]
irb(main):022:0> b = []; b << b
=> [[…]]
irb(main):023:0> a == b
SystemStackError: stack level too deep

I expected a result of true. Am I expecting too much? It might be hard
(or costly) to get this behavior. Array#== could remember (by calling
another function and passing along a hash argument throughout the
recursion) which pairs it has already compared…

This happens in 1.7.3 and 1.8.0.

I’m just asking out of curiosity.

How perverse :slight_smile: I am actually surpised that the inspect method is able
to make something out of it.

Are you the kind of guy that cannot be knocked away from between the two
mirrors in the fun-fair? :slight_smile:

···

On Fri, 22 Aug 2003 06:22:49 +0900, Joel VanderWerf vjoel@PATH.Berkeley.EDU wrote:

irb(main):021:0> a = ; a << a
=> [[…]]
irb(main):022:0> b = ; b << b
=> [[…]]
irb(main):023:0> a == b
SystemStackError: stack level too deep

I expected a result of true. Am I expecting too much? It might be hard
(or costly) to get this behavior. Array#== could remember (by calling
another function and passing along a hash argument throughout the
recursion) which pairs it has already compared…

This happens in 1.7.3 and 1.8.0.

I’m just asking out of curiosity.

Hi,

···

At Fri, 22 Aug 2003 18:57:09 +0900, Gerard A.W. Vreeswijk wrote:

SystemStackError: stack level too deep

I expected a result of true. Am I expecting too much? It might be hard
(or costly) to get this behavior. Array#== could remember (by calling
another function and passing along a hash argument throughout the
recursion) which pairs it has already compared…

How perverse :slight_smile: I am actually surpised that the inspect method is able
to make something out of it.

Are you the kind of guy that cannot be knocked away from between the two
mirrors in the fun-fair? :slight_smile:

Method #inspect uses thread local variable to propagate the
context. Inspection or traversal API would be required.


Nobu Nakada