miniqq 发表于 2009-12-22 17:11

有点变态的perl6语法?

你需要多少时间习惯?


----------------------------------------------------------------------
    say [+] 1, 2, 3;    # 6
    say [+] ();         # 0
    say [~] <a b>;      # ab
    say [**] 2, 3, 4;   # 2417851639229258349412352

    [\+] 1, 2, 3, 4   # 1, 3, 6, 10
    [\**] 2, 3, 4       # 4, 81, 2417851639229258349412352

    if [<=] @list {
      say "ascending order";
    }


----------------------------------------------------------------------
    if    [==] @nums { say "all nums in @nums are the same" }
    elsif [<]@nums { say "@nums is in strict ascending order" }
    elsif [<=] @nums { say "@nums is in ascending order"}

----------------------------------------------------------------------
    subset Squares of Int where { .sqrt.int**2 == $_ };

    multi sub square_root(Squares $x --> Int) {
      return $x.sqrt.int;
    }
    multi sub square_root(Num $x --> Num) {
      return $x.sqrt;
    }

----------------------------------------------------------------------
    my @integers = 0..*;
    for @integers -> $i {
      say $i;
      last if $i % 17 == 0;
    }

    my @even = map { 2 * $_ }, 0..*;
    my @stuff = gather {
      for 0 .. Inf {
            take 2 ** $_;
      }
    }

----------------------------------------------------------------------
    my $file = open '/etc/passwd', :r;
    for $file.lines -> $line {
      say $line;
    }

----------------------------------------------------------------------

af80 发表于 2009-12-22 17:18

Perl6 has some new features, those are what it should have, since most of them have owned by other popular languages like Python/Ruby while not Perl5.
Personally I best wish Perl6 come soon. Everything has been getting improved like Perl, but won't us?

Orchid in Ubuntu

cobrawgl 发表于 2009-12-22 18:05

多看几眼就习惯了,习惯了就会觉得好了

flw 发表于 2009-12-22 18:14

比较直观,很好理解。

ttcn_cu 发表于 2009-12-22 20:46

蛋疼
关键字越多,记忆难度越大,花在代码本省的书写上的时间就越多,花在逻辑分析上的时间越少

ttcn_cu 发表于 2009-12-22 20:47

不仅需要一本from c to perl,更需要一本from perl5 to perl6

blackold 发表于 2009-12-23 10:01

http://bbs2.chinaunix.net/images/smilies/icon_mrgreen.gif

flw 发表于 2009-12-23 10:09

原帖由 ttcn_cu 于 2009-12-22 20:46 发表 http://bbs3.chinaunix.net/images/common/back.gif
蛋疼
关键字越多,记忆难度越大,花在代码本省的书写上的时间就越多,花在逻辑分析上的时间越少
谬论

blackold 发表于 2009-12-23 10:12

还是比较喜欢Perl的自然语言特性。http://bbs2.chinaunix.net/images/smilies/icon_lol.gif

royalzhang 发表于 2009-12-23 13:03

语法很好。但是短期内还进入不了生产环境。
估计5的语法会慢慢过渡到6的。
页: [1] 2 3 4
查看完整版本: 有点变态的perl6语法?