# New Ticket Created by  "Stephen Simmons" 
# Please include the string:  [perl #125499]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=125499 >


It appears that using say on object1 which contains object2, which 
contains object1, causes Perl 6 to hang in an infinite loop, leaking 
memory (presumably gist is building an infinite string).

I'm not sure this is really a Perl 6 bug so much as a novice user 
experience issue. What I expected to happen was for the code to output a 
stringified version of the object, just an object name really. In 
studying gist in S02, it appears it is trying to create a string that 
represents the contents, and while long lists are truncated, circular 
loops are not handled. As I am not explicitly creating an infinite 
structure I did not expect Perl to when it evaluated the data.

This is an early experiment (for me) with Perl 6 classes, so any 
suggestions / corrections are of course welcome.

Versions:
This is perl6 version 2015.06-86-gacaeb17 built on MoarVM version 
2015.06-44-g2c96984
Linux bela 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 
x86_64 x86_64 x86_64 GNU/Linux

Sample code:
class Location {...}

class Item {
     has Location $.loc is rw;
     method locate (Location $l) { self.loc=$l; }
     method whereis () { return self.loc; }
}

class Location {
     has Item @.items;

     method put (Item $item) {
         push(@.items, $item);
     }
}

my $i1=Item.new;
my $l1=Location.new;
$l1.put($i1);
$i1.locate($l1);
say $i1.whereis;


Reply via email to