A suggestion about parrot sugar

2010-06-24 Thread Xi Yang

For example: "use parrot Foo::Bar", which would load parrot library under 
Foo/Bar. However, this would be easy and useful for rakudo, but would not for 
other possible Perl6 implementations. 
_
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969

Re: Two questions on Perl 6 functionality

2010-06-20 Thread Xi Yang

I still have several points unclear, this is my sample:
###
class Base {
method toHash() {
return {};
}
}
role FooBar {
has $.foo is rw;
has $.bar is rw;
toHash.wrap({
my $hash = callsame();
$hash = $self.foo;
return $hash;
});
}
class Compose is Base does FooBar {
}
my $obj = Compose.new(foo=>'foovalue', bar=>'barvalue');
my $data = $obj->toHash;###
1: It tells me "toHash" is not defined, as the role actually don't has that.
2: It seems that wrapping will affect the closure globally, but I only want 
class with specific role has specific modification.
> Date: Sun, 20 Jun 2010 13:53:59 +0200
> From: mor...@faui2k3.org
> To: jianding...@msn.com
> CC: perl6-users@perl.org
> Subject: Re: Two questions on Perl 6 functionality
> 
> 
> 
> Xi Yang wrote:
> > You might mis-understood method modifiers. I mean:
> > before x()
> > after x()
> > around x()
> > 
> 
> In Perl 6, you do that with wrapping:
> 
> http://perlcabal.org/syn/S06.html#Wrapping
> 
> 
> Cheers,
> Moritz

  
  
_
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969

RE: Two questions on Perl 6 functionality

2010-06-20 Thread Xi Yang

Very subtle implementation, I'm trying to understand those things. Thanks!
> Date: Sun, 20 Jun 2010 13:53:59 +0200
> From: mor...@faui2k3.org
> To: jianding...@msn.com
> CC: perl6-users@perl.org
> Subject: Re: Two questions on Perl 6 functionality
> 
> 
> 
> Xi Yang wrote:
> > You might mis-understood method modifiers. I mean:
> > before x()
> > after x()
> > around x()
> > 
> 
> In Perl 6, you do that with wrapping:
> 
> http://perlcabal.org/syn/S06.html#Wrapping
> 
> 
> Cheers,
> Moritz
  
_
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969

RE: Two questions on Perl 6 functionality

2010-06-20 Thread Xi Yang

You might mis-understood method modifiers. I mean:
before x()
after x()
around x()


> Date: Sun, 20 Jun 2010 12:17:46 +0200
> From: mor...@faui2k3.org
> To: jianding...@msn.com
> CC: perl6-users@perl.org
> Subject: Re: Two questions on Perl 6 functionality
> 
> Hi,
> 
> Xi Yang wrote:
> > 1: Does Perl 6 has method modifiers like those in Moose? 
> 
> Perl 6 has traits, so you can write for example
> 
> class A {
>method x() is rw { ...}
> }
> 
> to indicate that it's an lvalue routine (though I don't think it's
> implemented in Rakudo yet).
> 
> > Where can I get the doc about that? By reading apocalypse?
> 
> The Apocalypses are of historical interest only. Please read the
> Synopsis instead
> 
> http://perlcabal.org/syn/
> http://perlcabal.org/syn/S06.html
> http://perlcabal.org/syn/S12.html
> 
> 
> > 2: Does Perl 6 has build-in support for message passing (like those in Glib 
> > and Actionscript)?
> 
> I fear I'm not qualified to answer that, and I hope somebody else picks
> up the topic.
> 
> Cheers,
> Moritz
  
_
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969

Two questions on Perl 6 functionality

2010-06-19 Thread Xi Yang

1: Does Perl 6 has method modifiers like those in Moose? Where can I get the 
doc about that? By reading apocalypse?
2: Does Perl 6 has build-in support for message passing (like those in Glib and 
Actionscript)?
_
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969

Is there already have these utilities?

2010-06-17 Thread Xi Yang

Like those in perl5:
File::Spec;File::Path;Getopt::Long;
P.S.: There seems has something wrong with my damned windows hotmail, as it 
weirdly ignores newlines...   
_
Hotmail: Trusted email with powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969

RE: Something wrong with str.reverse

2010-06-17 Thread Xi Yang

Thanks!So the API has changed permanently?
> Date: Fri, 18 Jun 2010 13:29:11 +0800
> From: qiuhong...@gmail.com
> To: perl6-users@perl.org
> Subject: Re: Something wrong with str.reverse
> 
> 于 2010年06月18日 13:25, Xi Yang 写道:
> > I'm using rakudo 2010_05, with parrot 2.4.0. I found the $str.reverse just 
> > don't work at all:
> > $ perl6 -e 'my $str="abcde"; say $str; say $str.reverse;'abcdeabcde
> Use say $str.flip;  
_
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969

Something wrong with str.reverse

2010-06-17 Thread Xi Yang

I'm using rakudo 2010_05, with parrot 2.4.0. I found the $str.reverse just 
don't work at all:
$ perl6 -e 'my $str="abcde"; say $str; say $str.reverse;'abcdeabcde 
  
_
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969

Severe performance loss, comparing with perl 5

2010-06-12 Thread Xi Yang

I'm trying to use use Perl 6 to process some nucleotide sequences. However, I 
found it strangely slow on substr or string concat operations, compared with 
its Perl 5 equivalent.
Here are the codes, Perl 6 on top, Perl 5 on middle, a test input file on 
bottom (should be stored to "makeseq.fasta"). The Perl 6's revcom() sub works 
very slow.
#!/usr/bin/perl6use
 v6;use Bio::SeqIO;
say "program initialized";my $IN = Bio::SeqIO.new('fasta','makeseq.fasta');
say "input stream created";
while (my $obj = $IN.next_seq) {say "\tid: <",$obj.display_id,">";  
say "\tseq: <{$obj.seq}>";  say "\trev: <{revcom($obj.seq)}>";}
sub revcom(Str $seq) {  my $len = $seq.chars;   my $result; loop (my 
$i=$len-1; $i>=0; $i--) {  given ($seq.substr($i,1)) {  
   when ('A') {$result~='T'}   when ('T') 
{$result~='A'}   when ('G') {$result~='C'}  
 when ('C') {$result~='G'}   when ('a') {$result~='t'}  
 when ('t') {$result~='a'}   when ('g') 
{$result~='c'}   when ('c') {$result~='g'}   }  
 }   return 
$result;}
#!/usr/bin/perl
use strict;use Bio::SeqIO;use feature qw/say switch/;
say "program initialized";
my $IN = Bio::SeqIO->new(-file=>'makeseq.fasta');
say "input stream created";
while (my $obj = $IN->next_seq) {say "\tid: <",$obj->display_id,">";say 
"\tseq: <",$obj->seq,">";say "\trev: <",revcom($obj->seq),">";}
sub revcom {my $seq = shift;my $len = length $seq;  my $result; 
for (my $i=$len-1; $i>=0; $i--) {   given (substr $seq,$i,1) {  
when ('A') {$result.='T'}   when ('T') 
{$result.='A'}   when ('G') {$result.='C'}  
 when ('C') {$result.='G'}   when ('a') {$result.='t'}  
 when ('t') {$result.='a'}   when ('g') 
{$result.='c'}   when ('c') {$result.='g'}   }  
 }   return $result;}
>EMBOSS_001ccgacaacgaatatacgggctgtttgcttgcgtttgagaggtcgtattcccagatgcgtaacgtagcgctccactccgttcgaaaggccggaggaaacaatcgctgaacaactgggtagacataaccatgtcgtctctgtgctactcccccacgggtatattaaggcagataaggttgcttagtgggacctataac>EMBOSS_002cggattcagaattggacccggaagcatgcaggcgtggaatgtgggttaagggaccgaagtatttcgttactattccgatagtatccgatgagtccgtagcgggatgcacgtcataatcctagccttgaacgaccgggtactggttacgcaattccacccatgtaccttcccacagcccacatgcgacttatt>EMBOSS_003tctacgtatgggaataggacgtgctcaatacacgcatggcttgccgtccatcgggagcgttgcaagtcaaagagctaggcttaacctggactgagtggtcattgcgccgatgcacggcctgcctcagcgctgggagtaatcgtcaatagcaagtgtattgtagcgtcatcccaggcctcgaggcctaa>EMBOSS_004gttgccgaacgcgccactctcccgcggtgcttaatcgagttggactcaccacctaccacacaacaccggatgcgctaactccgggcatctgtcgcaaggcttcatggaaccctacactggtaatcatggtaatagattcaacgtgggttccgttcatatagacaccactcacaaaggcgttcgtgccctgat>EMBOSS_005atatcactcagcctgtggacgtgagccacccgcgctcactctcgctgtagattatgtcagagaacgtagaatctgtaatcatcggtcatatgaagtaatccaccgacaccgagcaacgttgctactgacaacgggacatttaagagtgctggaaattgagttattccgcctggataattggcggtttg
   
_
Hotmail: Trusted email with powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969