SystemStackError comparing self-referential structures

Discussion in 'Ruby' started by Joel VanderWerf, Aug 21, 2003.

  1. 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.
    Joel VanderWerf, Aug 21, 2003
    #1
    1. Advertising

  2. On Fri, 22 Aug 2003 06:22:49 +0900, Joel VanderWerf
    <> 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.
    >
    >


    How perverse :) 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? :)
    Gerard A.W. Vreeswijk, Aug 22, 2003
    #2
    1. Advertising

  3. Joel VanderWerf

    Guest

    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 :) 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? :)


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

    --
    Nobu Nakada
    , Aug 22, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
    Replies:
    0
    Views:
    446
  2. Anthony Heading

    typenames in self-referential templates

    Anthony Heading, Sep 24, 2003, in forum: C++
    Replies:
    9
    Views:
    455
    Shane Beasley
    Sep 25, 2003
  3. SpeedBump
    Replies:
    1
    Views:
    397
    David B. Held
    Nov 4, 2003
  4. Risto Lankinen

    Self-referential initialization

    Risto Lankinen, Nov 13, 2003, in forum: C++
    Replies:
    1
    Views:
    360
    tom_usenet
    Nov 13, 2003
  5. Joe
    Replies:
    5
    Views:
    532
    Barry Schwarz
    Dec 13, 2003
Loading...

Share This Page