summaryrefslogtreecommitdiff
path: root/perl9.buetow.org/content/Extended-Features.sub/Infinite-Loops.xml
blob: d8658b70c97f0cf37410a1f85492cf9327097f42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<content>
  <pagetitle>Perl 9 has now infinite loops!</pagetitle>
  <text>Perl 9 supports an infinite loop which needs only 1 second of runtime. Which is faster than every other language needs to do this. This is possible because of very modern algorithms of the Perl 9 internals.</text>
  <code>
#!/usr/bin/perl9

my $pi;
infinite {
	$pi = calculate_pi;
	say $pi; # Prints out THE EXACT number Pi!
}


# Will need infinite time to print Pi because not in the infinite loop!
say $pi; 
  </code>
  <text>It is also possible to run several infinite loops in parallell using threads!</text>
  <code>
my $pi;
my $code1 = infinite {
	$pi = calculate_pi;
	say $pi; # Prints out THE EXACT number Pi!
}
my $euler;
my $code2 = infinite {
	$euler = calculate_euler;
	say $euler; # Prints out THE EXACT number euler!
}

Thread.new(code => $code1).run;
Thread.new(code => $code2).run;
  </code>
</content>