.perl for self-referent structures #6

coke opened this Issue Oct 21, 2011 · 5 comments

5 participants


Pulled from https://rt.perl.org/rt3/Ticket/Display.html?id=58922

Subject:        .perl for self-referent structures
Date:   Tue, 16 Sep 2008 17:17:27 +0200
To:     rakudobug@perl.org
From:   "Carl M�sak" <cmasak@gmail.com>
Download (untitled) [text/plain 631b]
Calling .perl on a self-referent structure makes Rakudo r31152 hang.

$ ./perl6 -e 'my @a = (1); @a[0] := @a; @a.perl'

<masak> pmichaud: what about @a[0] := @a ?
<pmichaud> masak: I don't know about that one. :-)
<masak> :)
<pmichaud> part of me thinks that ends up with a self-referential structure
<masak> I hope so
<masak> that seems to be what's happening in at least one case in
Rakudo right now
<masak> question is, should .perl be able to handle that, and if so, how?
<moritz_> masak: it should
<moritz_> perhaps it should emit something like 'do { my @x = (...);
@x[0] := @x; @x }'
* masak submits rakudobug

#       Fri Nov 07 15:01:43 2008         pmichaud - Correspondence added                 [Reply] [Comment]
RT-Send-CC:     perl6-compiler@perl.org
Download (untitled) [text/plain 193b]
I'm going to mark this ticket as stalled until we have a good idea of
how self-referent structures should be handled in the output, either
through the spec itself or the spectests.


Perl 6 member

I see that this issue has been silent for two years. May I try to get the discussion unstuck by suggesting that .perl should handle circular references. We know it's eminently possible, because Perl 5's Data::Dumper already does this.

If people agree to that, the only remaining question is "how exactly should .perl display these circular references?" And that seems to me to be a question that need not block us — just do the simplest thing that works. It's more important in the short term that .perl not hang when presented with something circular.

Perl 6 member

I totally agree with making this issue unstuck. "Simplest thing that works" sounds good to me.


Perl 6 member

FWIW there is a significant difference between .perl methods and Data::Dumper; Data::Dumper has an obvious place to put the temporary data needed to find reference cycles (the Dumper sub itself). But as things currently stand in Perl 6 and the implementations, each .perl method only takes care about its own little invocant, recursively calls .perl on all members of its data structure.

So we need some kind of spec on where the cycle tracking data is stored, or how it is propagated from/by the individual .perl methods.

Perl 6 member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment