小牧今晚会把老的导上去。 在 2011年12月4日 下午4:47,Qiang (James) <[email protected]>写道:
> On 12/02/2011 07:07 PM, cnhack TNT wrote: > > advent.perlchina.org <http://advent.perlchina.org> 谁在管理?能否更新上 > > 去啊。。。现在居然跳到某个公司的页面去了。。。 > > > > 现在服务器由 Achilles 提供,我把这个问题和他说了,修复好后就可以看到以前 > 的 advent 了。 > > Qiang > > > > > > > 2011/12/2 Fayland Lam <[email protected] <mailto:[email protected]>> > > > > http://perlchina.github.com/advent.perlchina.org/2011/Moooo.html > > > > =for advent_year 2011 > > > > =for advent_day 2 > > > > =for advent_title qr/Moo?/ > > > > =for advent_author Woosley Xu > > > > 每个人都喜欢面向对象编程,于是每个人都喜欢L<Moose>。但是有些时候,Moose > > 的加载速度成为了我们应用的瓶颈。这时候L<Mouse>出现了,L<Class::Accessor> > > 出现了。但这还不够,L<Mouse>仍然过于沉重,L<Class::Accessor>仍然只能提供 > > 有限的特性。这时候,L<Moo>和L<Mo>出现了。 > > > > L<Moo>与L<Mouse>最大的区别是:它完全不提供任何B<meta object protocol>, > > 因此它的速度更快,体积更小。在将来的1.0版本,它计划可以和L<Any::Moose>一 > > 起使用。 > > > > 如果你仍然觉得L<Moo>太过重量级,那么L<Mo>是你的下一个选择。L<Mo>核心只提 > > 供B<new>,B<extends>,B<has>这些功能,但你可以按照需求加载你所需要的功能 > > 。 > > > > =begin code > > > > use Mo qw'build default builder coerce is required'; > > > > sub BUILD { > > my $self = shift; > > ... > > } > > > > =end code > > > > 你还可以轻松的将L<Mo>压缩,然后包括到你的模块中去。 > > > > =begin code > > > > >cat A.pm > > > > package A; > > # use Mo qw 'build default'; > > > > >mo-inline A.pm > > > > >cat A.pm > > > > package A; > > # use Mo qw 'build default'; > > # The following line of code was produced from the previous line by > > # Mo::Inline version 0.27 > > no > > warnings;my$M=__PACKAGE__.::;*{$M.Object::new}=sub{bless{@ > _[1..$#_]},$_[0]};*{$M.import}=sub{import > > warnings;$^H|=1538;my($P,%e,%o)=caller.::;shift;eval"no > > Mo::$_",&{$M.$_.::e}($P,\%e,\%o,\@_)for@_;return > > if$e{M};%e=(extends,sub{eval"no > > > $_[0]()";@{$P.ISA}=$_[0]},has,sub{my$n=shift;my$m=sub{$#_?$_[0]{$n}=$_[1]:$_[0]{$n}};$m=$o{$_}->($m,$n,@_)for > > sort keys%o;*{$P.$n}=$m},%e,);*{$P.$_}=$e{$_}for > > keys%e;@ > {$P.ISA}=$M.Object};*{$M.'build::e'}=sub{my($P,$e)=@_;$e->{new}=sub{$c=shift;my$s=bless{@ > _},$c;my@B;do{@B > =($c.::BUILD,@B)}while($c)=@{$c.::ISA};exists&$_&&&$_($s)for@B > ;$s}};*{$M.'default::e'}=sub{my($P,$e,$o)=@_;$o->{default}=sub{my($m,$n,%a)=@_;$a{default}or > > > return$m;sub{$#_?$m->(@_):!exists$_[0]{$n}?$_[0]{$n}=$a{default}->(@_):$m->(@_)}}};@f=qw[build > > default];use strict;use warnings; > > > > =end code > > > > 从 Moose 到 Moo 到 Mo,下一个会是 M ? :) > > > > 谢谢 > > > > > > -- > > Fayland Lam // http://www.fayland.org/ > > > > -- > > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论 > > 组”论坛。 > > 要向此网上论坛发帖,请发送电子邮件至 [email protected] > > <mailto:[email protected]>。 > > 要取消订阅此网上论坛,请发送电子邮件至 > > [email protected] > > <mailto:perlchina%[email protected]>。 > > 若有更多问题,请通过 > > http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 > > > > > > -- > > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 > > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > > 要取消订阅此网上论坛,请发送电子邮件至 > > [email protected]。 > > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN > > 访问此网上论坛。 > > -- > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 > > -- --------------------------- Achilles Xu -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
