The document discusses Pugs, an implementation of the Perl 6 programming language. It provides background on Pugs, describing it as a Perl 6 compiler, runtime, and test suite. It then discusses various aspects of Pugs such as its hybrid runtime architecture, support for multiple backends including Perl 5 and JavaScript, extensive testing, and open development model.
30. Perl, circa 2005
⢠use v6-alpha;
⢠use perl5:DBI;
⢠use perl5:Encode <encode decode>;
31. Perl, circa 2005
⢠use v6-alpha;
⢠use perl5:DBI;
⢠use perl5:Encode <encode decode>;
⢠use perl5:Template;
32. Perl, circa 2005
⢠use v6-alpha;
⢠use perl5:DBI;
⢠use perl5:Encode <encode decode>;
⢠use perl5:Template;
⢠# Implementation of "crypt"
eval "crypt()" :lang<perl5>;
143. Contexts
# Scalar vs. List context
my $one = <STDIN>; # Read one line
my @all = <STDIN>; # Read all lines
# String vs. Numeric context
print "Lines: @all" if @all < 10;
144. Tied Variables
tie my %search => 'Tie::Google';
print $search{'Perl Pugs'}[0]{URL};
# http://www.pugscode.org/
167. ⢠use v5;
⢠sub render {
⢠my $self = shift;
168. ⢠use v5;
⢠sub render {
⢠my $self = shift;
⢠my %opts = (x => 1, y => 1, z => 0, %{$_[0]});
169. ⢠use v5;
⢠sub render {
⢠my $self = shift;
⢠my %opts = (x => 1, y => 1, z => 0, %{$_[0]});
⢠for my $item ( $self->filter(@{ $self->{items} }) ) {
170. ⢠use v5;
⢠sub render {
⢠my $self = shift;
⢠my %opts = (x => 1, y => 1, z => 0, %{$_[0]});
⢠for my $item ( $self->filter(@{ $self->{items} }) ) {
⢠print $item->draw({
x => $opts{x},
y => $opts{y},
z => $opts{z},
}), "n";
171. ⢠use v5;
⢠sub render {
⢠my $self = shift;
⢠my %opts = (x => 1, y => 1, z => 0, %{$_[0]});
⢠for my $item ( $self->filter(@{ $self->{items} }) ) {
⢠print $item->draw({
x => $opts{x},
y => $opts{y},
z => $opts{z},
}), "n";
⢠}
}
240. ⢠# Lists are lazy by default
⢠my @fib := (
241. ⢠# Lists are lazy by default
⢠my @fib := (
⢠0, 1,
242. ⢠# Lists are lazy by default
⢠my @fib := (
⢠0, 1,
⢠each(@fib; @fib[1..*]).map(&infix:<+>)
);
243. ⢠# Lists are lazy by default
⢠my @fib := (
⢠0, 1,
⢠each(@fib; @fib[1..*]).map(&infix:<+>)
);
â˘
say "The first ten numbers are: @fib[^10]";
259. ⢠class Dog is Mammal does Companion {
â˘
my $.count where 0..100;
260. ⢠class Dog is Mammal does Companion {
â˘
my $.count where 0..100;
â˘
has $!brain;
261. ⢠class Dog is Mammal does Companion {
â˘
my $.count where 0..100;
â˘
has $!brain;
⢠has &.vocalize = &say;
has $.name is rw = "Fido";
262. ⢠class Dog is Mammal does Companion {
â˘
my $.count where 0..100;
â˘
has $!brain;
⢠has &.vocalize = &say;
has $.name is rw = "Fido";
⢠has $.fur handles Groomable;
has $.tail handles <wag hang>;
263. ⢠class Dog is Mammal does Companion {
â˘
my $.count where 0..100;
â˘
has $!brain;
⢠has &.vocalize = &say;
has $.name is rw = "Fido";
⢠has $.fur handles Groomable;
has $.tail handles <wag hang>;
â˘
method companion handles s/^owner_// { ... }
}
266. ⢠my Dog $fido .= new;
â˘
$fido.HOW; # the meta object for Dog
267. ⢠my Dog $fido .= new;
â˘
$fido.HOW; # the meta object for Dog
⢠$fido.WHAT; # the Dog prototype object
268. ⢠my Dog $fido .= new;
â˘
$fido.HOW; # the meta object for Dog
⢠$fido.WHAT; # the Dog prototype object
⢠$fido.WHICH; # $fidoâs Object ID
269. ⢠my Dog $fido .= new;
â˘
$fido.HOW; # the meta object for Dog
⢠$fido.WHAT; # the Dog prototype object
⢠$fido.WHICH; # $fidoâs Object ID
⢠Dog.isa(Dog); $fido.isa(Dog);