Skip to content

Instantly share code, notes, and snippets.

@Xliff
Last active August 25, 2019 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xliff/d4e9f86822e8340be50f4d544275c2b1 to your computer and use it in GitHub Desktop.
Save Xliff/d4e9f86822e8340be50f4d544275c2b1 to your computer and use it in GitHub Desktop.
Testing the depths of perl6...

So I was curious as to whether or not there were limits to the levels, or the type-name size for Perl6, and I wrote this script.

252 levels and 4299 characters in, I hit the shell limit.

I know how this can be fixed. Instead of writing one script per level, I need to write two.

If you're interested, here's the broken code. I'll keep this updated as progress allows:

use v6.c;

my @a = ('A'...'Z', 'a'...'z').flat;

my @names;

my $libdir = 'T';
mkdir $libdir unless $libdir.IO.d;
loop {
  my ($name, $use-line) = ( (@a.pick xx 15).join );

  my $fio-p = $libdir.IO;
  $fio-p .= add($_) for @names;

  ( my $fio-d = $fio-p ) .= add($name);
  mkdir $fio-d.absolute;

  my $mod = "{ @names.join('::') }{ '::' if @names }{ $name }";

  $use-line = "use { @names.join('::') };" if @names;
  $fio-p .= add($name ~ '.pm6');
  $fio-p.spurt: qq:to/FILE/;
    { $use-line // '' }
    class { $mod } { "is { @names.join('::') } " if @names }   \{ \}
    FILE

  # Now, attempt to use $name via external calal to perl6
  $*ERR.say: "Testing $mod --- { @names.elems } / { $mod.chars }...";
  my $proc = run
    <perl6 --stagestats -I>, $libdir, '-e',
    "use $mod";

  last if $proc.exitcode;

  @names.push: $name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment