<div class="slide">
<h1>Object Construction a la Moose</h1>
- <pre><code>Person->new(@_)</code></pre>
+ <pre><code>Person->new(@args)</code></pre>
<ol style="margin-top: 0">
- <li>Calls <code>Person->BUILDARGS(@_)</code> to turn <code>@_</code> into a hashref</li>
+ <li>Calls <code>Person->BUILDARGS(@args)</code> to turn <code>@args</code> into a hashref</li>
<li>Blesses a reference</li>
<li>Populates attributes based on the hashref from #1</li>
<li>Calls <code>$new_object->BUILDALL($constructor_args)</code>
<li>No <code>DEMOLISH()</code></li>
</ul>
</li>
- <li>But see <code>MooseX::NonMoose</code> for a workaround</li>
+ <li>But <code>MooseX::NonMoose</code> fixes all of this</li>
</ul>
</div>
<h1>Cleaning Up Moose Droppings</h1>
<pre><code>package Person;
-<span class="highlight">use namespace::autoclean;</span>
use Moose;
+<span class="highlight">use namespace::autoclean;</span>
...
# perl bin/prove -lv t/00-prereq.t
-# perl install-moose (if needed)
-
## Read the instructions in t/01-classes.t
# perl bin/prove -lv t/01-classes.t
</div>
<div class="slide">
- <h1>Name Conflicts Between Roles</h1>
-
- <pre><code>package HasSubProcess;
-use Moose::Role;
-
-<span class="highlight">sub execute { ... }</span>
-
-package Killer;
-use Moose::Role;
-
-with 'HasSubProcess';
-
-<span class="highlight">sub execute { ... }</span></code></pre>
-</div>
-
-<div class="slide">
<h1>Roles as Interfaces</h1>
<ul>
<h1>Attribute Inheritance</h1>
<ul>
- <li>By default, subclasses inherit attribute as-is</li>
+ <li>By default, subclasses inherit attributes as-is</li>
<li>Can change attribute parameters in subclasses</li>
</ul>
</div>
<li>alter parameters passed to the original method</li>
<li>alter the return value of the original method</li>
<li>not call the original method at all (or call a <em>different</em> method)</li>
- <li>When using modifiers in a role, require the modified method</li>
</ul>
</li>
+ <li>When using modifiers in a role, require the modified method</li>
</ul>
</div>
<h1>Subtype Shortcuts - <code>class_type</code></h1>
<pre><code>use Moose::Util::TypeConstraints;
-class_type 'DateTime';</code></pre>
+
+class_type 'DateTime';
+
+</code></pre>
<hr />
-<pre><code>subtype 'DateTime',
+<pre><code>
+subtype 'DateTime',
as 'Object',
where { $_->isa('DateTime') },
message { ... };</code></pre>
<h1>Subtype Shortcuts - <code>role_type</code></h1>
<pre><code>use Moose::Util::TypeConstraints;
-role_type 'Printable';</code></pre>
+
+role_type 'Printable';
+
+</code></pre>
<hr />
-<pre><code>subtype 'Printable',
+<pre><code>
+subtype 'Printable',
as 'Object',
where
{ Moose::Util::does_role(
<h1>Subtype Shortcuts - <code>duck_type</code></h1>
<pre><code>use Moose::Util::TypeConstraints;
-duck_type Car => qw( run break_down );</code></pre>
+
+duck_type Car => qw( run break_down );
+
+</code></pre>
<hr />
-<pre><code>subtype 'Car',
+<pre><code>
+subtype 'Car',
as 'Object',
where { all { $_->can($_) }
qw( run break_down ) },
<h1>Subtype Shortcuts - <code>enum</code></h1>
<pre><code>use Moose::Util::TypeConstraints;
-enum Color => qw( red blue green );</code></pre>
+
+enum Color => qw( red blue green );
+
+</code></pre>
<hr />
-<pre><code>my %ok = map { $_ => 1 }
+<pre><code>
+my %ok = map { $_ => 1 }
qw( red blue green );
subtype 'Color'
<pre><code>package Person;
<span class="highlight">my $posint =
- subtype as 'Int', where { $_ > 0 };</span>
+ subtype
+ as 'Int',
+ where { $_ > 0 };</span>
has size => (
is => 'ro',
<h1>Digression: The Type Registry</h1>
<ul>
- <li>Types are actually <code>Moose::Meta::TypeConstraints</code> <em>objects</em></li>
+ <li>Types are actually <code>Moose::Meta::TypeConstraint</code> <em>objects</em></li>
<li>Stored in an interpreter-global registry mapping names to objects</li>
</ul>
</div>
</div>
<div class="slide">
+ <h1>Specio</h1>
+
+ <ul>
+ <li>My attempt to replace <code>MooseX::Types</code> <strong>and</strong> built-in types</li>
+ <li>Third-system effect?</li>
+ <li>Still alpha - needs some work</li>
+ </ul>
+</div>
+
+<div class="slide">
<h1>Recommendation</h1>
<ul>
- <li>Use <code>MooseX::Types</code></li>
+ <li>Use <code>MooseX::Types</code> for now</li>
+ <li>Switch to <code>Specio</code> when it's ready?</li>
<li>Compile time error catching and automatic namespacing are huge wins</li>
<li>Docs from <code>Moose::Util::TypeConstraints</code> are 98% compatible with <code>MooseX::Types</code> anyway</li>
<li>A function exported by a type library works wherever a type name would</li>
<li>mailing list - <a href="mailto:moose@perl.org">moose@perl.org</a></li>
<li>Slides and exercises are in Moose's git repo:
<br />
- <span style="font-size:80%; white-space: nowrap">git://jules.scsys.co.uk/gitmo/moose-presentations</span></li>
+ <span style="font-size:80%; white-space: nowrap">git://git.moose.perl.org/moose-presentations.git</span></li>
</ul>
</div>
<!--
-Copyright 2009 David Rolsky. All Rights Reserved.
+Copyright 2009-2013 David Rolsky. All Rights Reserved.
This work is licensed under a Creative Commons Attribution-Share Alike
3.0 United States License See