Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive data structures hang when .perl'd #3437

Closed
p6rt opened this issue Jul 14, 2014 · 5 comments
Closed

recursive data structures hang when .perl'd #3437

p6rt opened this issue Jul 14, 2014 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Jul 14, 2014

Migrated from rt.perl.org#122286 (status was 'resolved')

Searchable as RT122286$

@p6rt
Copy link
Author

p6rt commented Jul 14, 2014

From @coke

S02-names-vars/perl.t

has several examples of recursive data structures that must be skipped
because calling .perl on them hangs.

e.g.​:

  my $foo = { a => 42 }; $foo<b> = $foo;
  is $foo<b><b><b><a>, 42, "basic recursive hashref";

  is ~$foo.perl.EVAL, ~$foo,
  ".perl worked correctly on a recursive hashref";

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jun 28, 2015

From @stifynsemons

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;

@p6rt
Copy link
Author

p6rt commented Sep 24, 2015

From @niner

Fixed in rakudo commit 397e221b4e205d0257ba2284f3792f07735c9c6d, roast commit a9f090cc42ce3425f770975918d6a53a08700fed

@p6rt
Copy link
Author

p6rt commented Sep 24, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 24, 2015

@niner - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Sep 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant