First time with Pugs

tombom on 2005-03-18T19:37:39

Today I decided to try and test Pugs to see how well it does. Here was my first try:

pugs> my x = 2
*** Error:
unexpected "x"
expecting variable name or "("
  at  at line 1, column 4
pugs> my $x = 2;
2
pugs> my $x = "a";
'a'
pugs> my $x is Int = "a";
*** Error: No compatible subroutine found: &is
  at App "&is" (App "&Int" (App "&prefix:=" (Syn "cxt"
                                             {'Str';
                                              App "&infix:~" ('a',
                                                              '')})))
pugs> my Int $x = 1;
*** Error:
unexpected "I"
expecting variable name or "("
  at  at line 1, column 4


That didn't go to well. So now I start reading some more synopses 'n' stuff and come up with this:

pugs> my $a = sub { say "a" }
sub {...}
pugs> $a->()
*** Error:
unexpected ">" or "-"
expecting word character, ":", term postfix, operator, postfix conditional, post
fix loop, postfix iteration, ";" or end of input
  at  at line 1, column 3
pugs> $a()
a
bool::true


Wayhey! Looks almost like perl5. And I can now produce this:
#!perl6
use v6;

my @tags = ("AMI ","ENG ","FRA ","SPA ","CAS ","A ","B ","C ","D ");

sub get_r_tags($a) { my @b = (); for(1..$a) { push @b, @tags[rand(@tags)]; } return @b; }

say get_r_tags(3);


Looks like there's hope for my CK random scenario thing in perl6 yet :)