1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 <html xmlns="http://www.w3.org/1999/xhtml">
10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
11 <meta name="generator" content="TextMate/S5" />
12 <meta name="version" content="S5 1.2a2" />
13 <meta name="presdate" content="2008" />
14 <meta name="author" content="Yuval Kogman" />
15 <meta name="company" content="" />
16 <!-- configuration parameters -->
17 <meta name="defaultView" content="slideshow" />
18 <meta name="controlVis" content="visible" />
19 <!-- style sheet links -->
20 <link rel="stylesheet" href="./ui/moose/slides.css" type="text/css" media="projection" id="slideProj" />
21 <link rel="stylesheet" href="./ui/moose/outline.css" type="text/css" media="screen" id="outlineStyle" />
22 <link rel="stylesheet" href="./ui/moose/print.css" type="text/css" media="print" id="slidePrint" />
23 <link rel="stylesheet" href="./ui/moose/opera.css" type="text/css" media="projection" id="operaFix" />
24 <!-- embedded styles -->
25 <style type="text/css" media="all">
26 .imgcon {width: 525px; margin: 0 auto; padding: 0; text-align: center;}
27 #anim {width: 270px; height: 320px; position: relative; margin-top: 0.5em;}
28 #anim img {position: absolute; top: 42px; left: 24px;}
29 img#me01 {top: 0; left: 0;}
30 img#me02 {left: 23px;}
32 img#me05 {top: 43px;left: 36px;}
35 <script src="./ui/moose/slides.js" type="text/javascript"></script>
40 <div id="controls"><!-- DO NOT EDIT --></div>
41 <div id="currentSlide"><!-- DO NOT EDIT --></div>
42 <div id="header"></div>
44 <h1>YAPC::Asia::2008</h1>
47 <div class="topleft"></div>
48 <div class="topright"></div>
49 <div class="bottomleft"></div>
50 <div class="bottomright"></div>
53 <div class="presentation">
64 <h1>Moose はなにではないか</h1>
69 <li>実験やプロトタイプ (experimental)</li>
71 <li>もう一つのアクセサビルダー (accessor builder)</li>
72 <li>ソースフィルタ (source filter)</li>
73 <li>黒魔術 (black magic)</li>
74 <li>Perl 6 in Perl 5</li>
85 <li><p>Perlのための完全にモダンなオブジェクトフレームワーク</p></li>
86 <li><p>A complete modern object framework for Perl</p></li>
97 <li>Class::MOPのためのシンタックスシュガー (Syntactic sugar)</li>
100 <li>CLOS (Common Lisp Object System)</li>
102 <li>Alces latifrons</li>
106 <li>安定していて、お仕事にもつかえます (Stable & Production ready)</li>
114 <h2>A Simple Example</h2>
132 my ($self, $name) = @_;
133 $self->{'name'} = $name if $name;
134 return $self->{'name'};
138 my ($self, $age) = @_;
139 $self->{'age'} = $age if $age;
140 return $self->{'age'};
149 <h1>シンプルなMooseの例</h1>
151 <h2>A Simple Moose Example</h2>
157 has name => (is => 'rw');
158 has age => (is => 'rw');
166 <h1>シンプルなMooseの例(つづき)</h1>
168 <h2>A Simple Moose Example (cont.)</h2>
171 <li><code>use Moose;</code>
173 <li>キーワードをインポート (imports keywords)</li>
174 <li><code>use strict; use warnings;</code></li>
175 <li><code>@ISA = qw(Moose::Object) unless @ISA</code></li>
182 <h1>シンプルなMooseの例(つづき)</h1>
184 <h2>A Simple Moose Example (cont.)</h2>
187 <li><p><code>has</code> はアトリビュートを定義する (declares attibutes)</p>
190 <li>アクセサを生成 (generates accessors)</li>
191 <li><code>is => 'rw'</code> → 読み書き両用アクセサ</li>
192 <li><code>is => 'ro'</code> → 読み込み専用アクセサ</li>
193 <li><code>writer</code>, <code>reader</code></li>
195 <li><p><code>new</code> は <code>Moose::Object</code> から継承する</p></li>
199 <p>今度はアトリビュートの機能を説明していくよ
200 Now we’re going to discuss more features of the attributes</p>
205 <h1>Mooseの例のバリエーション</h1>
207 <h2>Variations on a Moose Example</h2>
223 default => sub { [qw(Bob Alice Tim)] },
228 <p>default と isa が追加されてます
229 Adds default, isa</p>
234 <h1>Mooseの例のバリエーション(つづき)</h1>
236 <h2>Variations on a Moose Example (cont.)</h2>
239 <li><p><code>default</code> は</p>
242 <li>コードリファレンス (coderef)</li>
243 <li>またはリファレンス以外 (数値, 文字列) (nonref)</li>
244 <li><code>new</code> にパラメータがわたされなかったときに使われる</li>
246 <li><p><code>lazy</code> は <code>default</code> を遅延させる</p>
249 <li>最初に <code>$object->staff</code> が使われたときに呼ばれる (generates)</li>
250 <li><code>new</code> の中ではなく (no param)</li>
256 discusses default</p>
258 <p>リファレンスでないと想定外の共有がむずかしくなる
259 non refs make accidental sharing hard</p>
264 <h1>Mooseの例のバリエーション(つづき)</h1>
266 <h2>Variations on a Moose Example (cont.)</h2>
269 <li><code>isa</code> は型を規定する (specifies type)
271 <li><code>Moose::Util::TypeConstraints</code>
273 <li><code>Any, Item, Bool, Undef, Defined, Value, Num, Int, Str, Ref, ScalarRef, ArrayRef, HashRef, CodeRef, RegexpRef, GlobRef, FileHandle, Object, and Role</code></li>
275 <li>型は存在する必要はありません (don’t need to exist)</li>
280 has 'date' => (isa => 'DateTime'); # DWIM
285 isa, type constraints</p>
292 <h2>Typical Family</h2>
295 <li>型は階層構造をもっている (types have a hierarchy)
297 <li><code>Item</code> ⊃ <code>Defined</code> ⊃ <code>Ref</code> ⊃ <code>Object</code></li>
304 => where { ref($_) };
308 => where { blessed($_) }
320 <h2>Some Type of Coercion</h2>
325 use Moose::Util::TypeConstraints;
328 class_type 'Manager';
332 => via { Manager->new( name => $_) };
347 <h2>Some Type of Coercion (cont.)</h2>
350 # 型制約のキーワードをインポート(import type constraint keywords)
351 use Moose::Util::TypeConstraints;
354 # オブジェクトのサブタイプであるマネージャーを定義(define Manager, a subtype of Object)
355 class_type "Manager";
358 # 変換を定義する(define the conversion)
361 => via { Manager->new( name => $_) };
364 # アトリビュートごとに有効にする(enable it per attribute)
373 breakdown of the example</p>
375 <p>クラスの型はMooseのクラスすべてに自動的に用意されます
376 class types are automatically created for all Moose classes</p>
383 <h2>Conventional Delegates</h2>
394 manager_name => 'name',
395 coworkers => 'staff',
401 <li>マネージャーは <code>Employee</code> のいくつかのメソッドを処理します</li>
402 <li>manager <code>handles</code> certain methods for <code>Employee</code>
404 <li><code>$emp->coworkers</code> == <code>$emp->manager->staff</code></li>
413 <h2>Conventional Delegates (cont.)</h2>
418 handles => [qw(number extension)],
427 <h2>Conventional Delegates (cont.)</h2>
432 handles => qr/$method_regex/,
437 <li><code>Phone->meta->compute_all_applicable_methods</code>にフィルターをかける</li>
438 <li>Filters <code>Phone->meta->compute_all_applicable_methods</code></li>
446 <h2>Conventional Delegates (cont.)</h2>
451 handles => "Dialing", # a role
460 <h2>UnConventional Delegates</h2>
465 use MooseX::AttributeHelpers;
468 metaclass => 'Collection::Array',
469 isa => 'ArrayRef[Employees]',
472 push => 'add_employee',
473 pop => 'remove_employee',
474 count => 'number_of_employees',
475 empty => 'any_employees',
485 <h2>Modified Methods</h2>
488 before 'employees' => sub { warn 'calling employees' };
490 after 'employees' => sub { warn 'finished calling employees' };
494 <li>現在のメソッドが実行される前/された後に実行されます</li>
497 <li><code>@_</code>のコピーを得ます(Get a copy of <code>@_</code>)</li>
498 <li>返り値は無視されます(Return value is ignored)</li>
505 <h1>メソッド変更のセカイ(つづき)</h1>
507 <h2>Modified Methods (cont.)</h2>
510 around 'employees' => sub {
511 my ($next, $self, @args) = @_;
513 my @return = $self->$next(@args);
522 <h1>メソッド変更のセカイ(つづき)</h1>
524 <h2>Modified Methods (cont.)</h2>
535 inner(); # call subclass here
544 <h1>メソッド変更のセカイ(つづき)</h1>
546 <h2>Modified Methods (cont.)</h2>
549 package Employee::Chef;
552 extends qw(Employee);
554 augment do_work => sub {
558 $self->flip_burger(shift @burgers);
562 $chef->do_work; # punch in, flip burgers, punch out
570 <h2>Some Type of Digression</h2>
575 isa => 'ArrayRef[Employee]',
578 has shopping_carts => (
580 isa => 'ArrayRef[ArrayRef[ShinyBead]]'
585 <p>型システムの機能についてちょっと説明していくよ
586 Going to go into features of the type system for a bit</p>
589 Parametrized types</p>
594 <h1>型についての余談(つづき)</h1>
596 <h2>Some Type of Digression (cont.)</h2>
601 isa => 'English | Welsh | Scots | Gaelic',
606 isa => 'Employee | ArrayRef[Employee|Group]',
617 <h1>型についての余談(つづき)</h1>
619 <h2>Some Type of Digression (cont.)</h2>
624 use Moose::Util::TypeConstraints;
625 use Test::Deep qw(eq_deeply ...);
627 type 'SomethingTricky'
629 eq_deeply( $_, ... );
634 isa => 'SomethingTricky',
639 <p>Test::Deppのカスタムバリデータ
640 Test::Deep custom validator</p>
642 <p>CPANからどんなバリデータでも持ってこられる
643 Can use any validation from the CPAN</p>
648 <h1>パラメータ付きの型の強制変換</h1>
650 <h2>Some Parametrized Type of Coercion</h2>
653 use Moose::Util::TypeConstraints;
654 subtype 'ArrayRef[Employee]' => as 'ArrayRef';
656 coerce 'ArrayRef[Employee]'
657 => from 'ArrayRef[Str]'
658 => via { [ map { Employee->new( name => $_ ) } @$_ ] };
662 isa => 'ArrayRef[Employee]',
664 default => sub { [qw(Bob Alice Tim)] },
670 <p>ArrayRef[Str] から ArrayRef[Employee] に強制変換
671 coerce parametrized ArrayRef[Employee] from ArrayRef[Str]</p>
673 <p>強制変換は ‘default’ の返り値にも適用されます
674 coercions can be applied to ‘default’ return values</p>
681 <h2>Role of the Moose</h2>
684 <li>Role は…(A role is like a)
686 <li>JavaのInterfaceみたい</li>
688 <li>…それでいて安全でパワフル(safe, powerful)</li>
690 <li>Role は小さくて再利用可能な動作向け(A role is for small reusable behaviors)
692 <li>多重継承よりよい(better than using a multiple inheritence)</li>
699 <h1>MooseのRole(つづき)</h1>
701 <h2>Role of the Moose (cont.)</h2>
704 <li>CPAN にある Role たち(Roles on the CPAN):
706 <li><code>MooseX::Storage</code> - 柔軟なシリアライズ(Flexible serialization)</li>
707 <li><code>MooseX::LogDispatch</code> - <code>$self->logger->info("something happenned")</code></li>
708 <li><code>MooseX::Getopt</code> - コマンドライン引数の処理(<code>@ARGV</code> aware constructor)</li>
709 <li><code>MooseX::Param</code> - <code>CGI.pm</code> の <code>param()</code> メソッドみたいなの(<code>param</code> method like <code>CGI.pm</code>’s)</li>
710 <li><code>MooseX::Clone</code> - 柔軟な<code>clone</code>メソッド(Flexible <code>clone</code> method)</li>
716 Some examples of small reusable behaviors</p>
719 Param is good for interacting with e.g. CGI::Expand or similar modules</p>
724 <h1>MooseのRole(つづき)</h1>
726 <h2>Role of the Moose (cont.)</h2>
732 extends qw(Employee);
734 with qw(Salaried::Hourly);
739 extends qw(Employee);
741 with qw(Salaried::Monthly);
746 <li><code>with</code> はクラスに Role を追加します</li>
747 <li><code>with</code> adds roles into your class
749 <li><code>Salaried::Hourly</code>が<code>Minion</code>に追加される</li>
750 <li><code>Salaried::Hourly</code> was added to <code>Minion</code></li>
757 <h1>MooseのRole(つづき)</h1>
759 <h2>Role of the Moose (cont.)</h2>
765 requires qw('paycheck_amount');
770 <li>Just an interface</li>
776 <h1>MooseのRole(つづき)</h1>
778 <h2>Role of the Moose (cont.)</h2>
781 package Salaried::Hourly;
792 has logged_hours => (
798 sub paycheck_amount {
801 $self->logged_hours * $self->hourly_rate;
807 <li>インターフェースよりイイネ!</li>
808 <li>More than an interface</li>
814 <h1>MooseのRole(つづき)</h1>
816 <h2>Role of the Moose (cont.)</h2>
819 <li>Javaのインターフェースよりイイネ!</li>
820 <li>More than Java Interfaces
822 <li>インターフェースは挙動の’規定’を提供する</li>
823 <li>Interfaces are behavior “contracts”</li>
824 <li>Role は挙動の’実装’も提供できる</li>
825 <li>Roles can also have code</li>
830 <p>Roleはアトリビュートとメソッドを持てる
831 roles can have attributes and methods
832 Roleはインターフェースだけでなく動作を提供するもの
833 roles provide behavior, not just interface</p>
838 <h1>MooseのRole(つづき)</h1>
840 <h2>Role of the Moose (cont.)</h2>
843 <li>Roleの組み込み(Role Composition)
845 <li>継承ではない(Not inheritence)</li>
846 <li>喧嘩両成敗(Symmetric)</li>
847 <li>順序は関係ない(Unordered)</li>
854 <h1>MooseのRole(つづき)</h1>
856 <h2>Role of the Moose (cont.)</h2>
859 <li>Roleの組み込み(Role Composition)
861 <li>あいまいさが少ない(Less ambiguity)</li>
862 <li>コンパイル時エラー(Compile time errors)</li>
863 <li>…修正する方法もある(And ways to fix them)</li>
868 <p>喧嘩両成敗というのは優先順位がないということ。ふたつのRoleが同じものを定義しようとした場合はコンパイル時にエラーになる(直さないといけない)
869 symmetric composition means no precedence - if two roles try to define the same thing you get a compile time error that needs to be resolved
870 多重継承の場合はだまって最初のクラスを使うもんだと想定してしまう
871 multiple inheritence silently assumes you want the first class</p>
873 <p>Roleは多重継承と違ってコンパイル時にエラーを吐く
874 roles cause errors at compile time, unlike multiple inheritence</p>
876 <p>Roleは簡単にエラーを修正する方法も用意している
877 roles also provide easy ways to fix the errors</p>
882 <h1>MooseのRole(つづき)</h1>
884 <h2>Role of the Moose (cont.)</h2>
914 <h1>MooseのRole(つづき)</h1>
916 <h2>Role of the Moose (cont.)</h2>
930 bark => "bark_sound",
948 Composition parameters
950 Easier conflict resolution
951 よりきめ細かいコントロールができるようになる
952 Finer grained control</p>
959 <h2>MOPs Mean Cleanliness</h2>
962 <li>Moose は Class::MOP でつくられてる</li>
963 <li>Moose is based on <code>Class::MOP</code>
965 <li>Perl5のためのメタオブジェクトプロトコル(Metaobject Protocol for Perl 5)</li>
966 <li>すべてにオブジェクトがつくられる(“makes an object for everything”)</li>
971 my $class = $obj->meta; # $objのメタクラス($obj's metaclass)
972 my $meta = MyApp->meta; # MyAppのメタクラス(MyApp's metaclass)
973 my $emo = $obj->meta->meta # メタメタ(even more meta)!
975 warn $obj->meta->name;
983 <h2>Looking in From the Inside</h2>
986 my $metaclass = $self->meta;
988 $metaclass->superclasses;
990 $metaclass->linearized_isa; # すべての先祖クラスを得ます(returns all ancestors)
992 $metaclass->has_method("foo");
994 $metaclass->compute_all_applicable_methods; # すべてのメソッド(継承されたものもふくめて)(returns all methods (inherited too))
996 $metaclass->has_attribute("bar");
1002 <p>simple introspection</p>
1007 <h1>内側からみてみる(つづき)</h1>
1009 <h2>Looking in From the Inside (cont.)</h2>
1012 Moose::Meta::Class->create( Bar =>
1014 superclasses => [ 'Foo' ],
1016 Moose::Meta::Attribute->new( bar => ... ),
1017 Moose::Meta::Attribute->new( baz => ... ),
1020 calculate_bar => sub { ... },
1021 construct_baz => sub { ... }
1027 <p>クラスはプログラム的につくることもできる
1028 Classes can be created programmatically</p>
1031 Anonymous classes also possible</p>
1036 <h1>内側からみてみる(つづき)</h1>
1038 <h2>Looking in From the Inside (cont.)</h2>
1041 has foo => ( is => "rw" );
1043 __PACKAGE__->meta->add_attribute( foo => is => "rw" );
1047 <li>Mooseは単なるシュガー(Moose is just sugar)
1049 <li>大変な部分はMOPがしてくれる(The MOP does the hard work)</li>
1058 <h2>The Metaclass Tango</h2>
1061 <li>メタクラスはクラスの挙動をコントロールする</li>
1062 <li>Metaclassses control class behavior</li>
1067 metaclass => 'Collection::Array',
1073 <li>カスタムアトリビュートメタクラスは</li>
1074 <li>custom attribute metaclasses
1076 <li>アトリビュートがどういう風に動くかを変える</li>
1077 <li>change how attributes work</li>
1079 <li>カスタマイズ可能なパーツたち</li>
1080 <li>Many customizable parts
1082 <li><code>Moose::Meta::Class</code>, <code>Moose::Meta::Attribute,</code><code>Moose::Meta::Method</code>, <code>Moose::Meta::Method::Accessor</code> <code>Moose::Meta::Instance</code>, <code>Moose::Meta::Role</code>, <code>Moose::Meta::TypeConstraint</code>, …,</li>
1091 <h2>Working in the Meta Frame</h2>
1094 <li>仕事であったおもろい話(An interesting <code>$work</code> story)</li>
1095 <li>flashを使ったサイト用のCMS(CMS for a flash website)</li>
1096 <li>コンテンツはXML(Content is in XML)</li>
1102 <h1>メタフレームを使う(つづき)</h1>
1104 <h2>Working in the Meta Frame (cont.)</h2>
1107 <li>Step 1. use Moose</li>
1108 <li>Step 2. ???</li>
1109 <li>Step 3. 金(Profit)!</li>
1115 <h1>メタフレームを使う(つづき)</h1>
1117 <h2>Working in the Meta Frame (cont.)</h2>
1120 <li>Step 2.1. XMLスキーマ(schemas) → クラス(classes)
1122 <li>自動変換(Automatic conversion)
1124 <li>MOPのおかげで楽勝(MOP makes it easy)</li>
1126 <li>実行時には高レベルオブジェクト(High level objects in runtime)</li>
1127 <li>裏ではXML(XML backed)
1129 <li>クライアントのスキーマ(With client’s schemas)</li>
1130 <li>SAX → Moose</li>
1131 <li>Moose → SAX</li>
1139 <h1>メタフレームを使う(つづき)</h1>
1141 <h2>Working in the Meta Frame (cont.)</h2>
1144 <li>Step 2.2. メタ記述(Meta descriptions)
1146 <li>メタクラスを拡張(Extend the metaclasses)</li>
1147 <li>追加の情報を埋め込む(Embed additional information)
1149 <li>フィールド型(field types)</li>
1150 <li>アクセスコントロール(access control)</li>
1158 <h1>メタフレームを使う(つづき)</h1>
1160 <h2>Working in the Meta Frame (cont.)</h2>
1163 <li>Step 2.3 イントロスペクションかわゆす(Introspection goodness)
1165 <li>汎用Webフロントエンド(Generic web frontend)</li>
1166 <li>オブジェクトイントロスペクションベース(Object introspection based)
1168 <li>HTMLビュー(view)</li>
1169 <li>編集用のウィジェット(Editing widgets)</li>
1171 <li>クリーンで拡張性も高い(Clean, extensible)</li>
1180 <h2>Drawbacks of Moose</h2>
1183 <li>ロード時間(Load time)
1185 <li><code>MooseX::Compile</code> がアルでよ(<code>MooseX::Compile</code> is in the works)</li>
1187 <li>いくつかの機能が遅い(Some features are slow)
1189 <li>でも、あなたがつかったぶんだけだから(but you only pay for what you use)</li>
1191 <li>hashref じゃないクラスの拡張はトリッキー(Extending non-Hash based classes is tricky).
1193 <li>でも可能(but possible): <code>MooseX::GlobRef::Object</code></li>
1200 <h1>Mooseのイイ!とこ</h1>
1202 <h2>Benefits of Moose</h2>
1205 <li>退屈なことを減らせる(Less tedious)
1207 <li>決まり文句を書かなくていい(ditch that boilerplate):
1209 <li>アトリビュートのストレージ/アクセサ(attribute storage/access)</li>
1210 <li>コンストラクタ(construction)</li>
1211 <li>デストラクタ(destruction)</li>
1212 <li>引数検査(verification)</li>
1215 <li>繰り返しを減らせる(less repetition)</li>
1216 <li>typo を減らせる(fewer typos)</li>
1223 <h1>Mooseのイイ!とこ(つづき)</h1>
1225 <h2>Benefits of Moose (cont.)</h2>
1230 <li>declarative == 情報がおおく、タイプ数がすくない(more info, less typing)</li>
1232 <li>コードがすくなきゃバグもすくなかろう(less code means fewer bugs)</li>
1239 <h1>Mooseのイイ!とこ(つづき)</h1>
1241 <h2>Benefits of Moose (cont.)</h2>
1244 <li>テストがすくなくていい(Less testing)
1246 <li>Moose はよくテストされておる</li>
1247 <li>Moose is well tested
1249 <li>アクセサやら挙動やらをチェックせんでもよろし</li>
1250 <li>no need to check accessor behavior, etc</li>
1252 <li>あなたのコードの目的にフォーカスできます!</li>
1253 <li>focus on your code’s purpose
1255 <li>きちんと「まとめて」おかなくてもいいよ</li>
1256 <li>not that it is “assembled” correctly</li>
1257 <li>http://c2.com/cgi/wiki?IntentionNotAlgorithm</li>
1265 <h1>Mooseのイイ!とこ(つづき)</h1>
1267 <h2>Benefits of Moose (cont.)</h2>
1270 <li>読みやすい(More readable)
1272 <li>宣言的なスタイルだからそのまま文書になっている</li>
1273 <li>declarative style is self documenting</li>
1274 <li>やりたいことを書け。関係ないOOのしかけとかはあまり書かなくてもいい</li>
1275 <li>Code your intentions, not and OO mechanics less</li>
1282 <h1>Mooseのイイ!とこ(つづき)</h1>
1284 <h2>Benefits of Moose (cont.)</h2>
1287 <li>Meta object protocol
1289 <li>Perl の OO を綺麗にあつかえます</li>
1290 <li>Cleans up all levels of Perl’s OO</li>
1291 <li>イントロスペクションできます</li>
1292 <li>Provides introspection</li>
1294 <li>Enables powerful abstractions</li>
1301 <h1>Mooseのイイ!とこ(つづき)</h1>
1303 <h2>Benefits of Moose (cont.)</h2>
1307 <li>It’s the new black
1309 <li>イカした連中はみんな#mooseにきている</li>
1310 <li>All the cool kids hang out on #moose</li>
1311 <li>かっこよさげなバズワード</li>
1312 <li>Smart sounding buzzwords</li>
1313 <li>2007年にはRubyがそうだったね</li>
1314 <li>Ruby is so 2007</li>
1323 <h2>Bonus Material</h2>
1331 package Units::Bytes;
1336 sub kilobytes { $_[0] * 1024 }
1337 sub megabytes { $_[0] * 1024->kilobytes }
1338 sub gigabytes { $_[0] * 1024->megabytes }
1339 sub terabytes { $_[0] * 1024->gigabytes }
1341 Moose::Autobox->mixin_additional_role(SCALAR => 'Units::Bytes');
1347 <h1>Autobox (つづき)</h1>
1349 <h2>Autobox (cont.)</h2>
1355 is(5->bytes, 5, '... got 5 bytes');
1356 is(5->kilobytes, 5120, '... got 5 kilobytes');
1357 is(2->megabytes, 2097152, '... got 2 megabytes');
1358 is(1->gigabytes, 1073741824, '... got 1 gigabyte');
1359 is(2->terabytes, 2199023255552, '... got 2 terabyte');
1365 <h1>perl -Moose</h1>
1368 <li>Moose なワンライナーには <code>oose.pm</code> があるでよ</li>
1369 <li>Moose One Liners with <code>oose.pm</code></li>
1373 perl -Moose -e'has foo => (is=>q[rw]); Class->new(foo=>1)'
1377 <li>なんかためしたいときなどに</li>
1378 <li>Useful for testing if something works</li>
1379 <li>IRC での会話には欠かせませんな!</li>
1380 <li>Nice for IRC</li>
1386 <h1>MooseX::POE</h1>
1399 $self->yield('increment');
1402 event increment => sub {
1404 warn "Count is now " . $self->count;
1405 $self->count( $self->count + 1 );
1406 $self->yield('increment') unless $self->count > 3;
1409 Counter->new( count => 0 );
1414 <li>POE のコンポーネントを簡単にかけます</li>
1415 <li>POE components made easy</li>
1416 <li>それぞれのオブジェクトが POE::Session をもってます</li>
1417 <li>Every object has a POE::Session</li>
1418 <li><code>event</code> がオブジェクトのステートを宣言します</li>
1419 <li><code>event</code> declares object states</li>
1428 <li><p>Slides written by:</p>
1431 <li>Chris Prather</li>
1432 <li>Stevan Little</li>
1433 <li>Robert Boone</li>
1435 <li><p>Slides deleted by:</p>
1438 <li>Yuval Kogman</li>
1440 <li><p>Slides translated by:</p>