);
# kaboom
-Person->new( weight => 'fat' );</code></pre>
+Person->new( weight => 'heavy' );</code></pre>
</div>
<div class="slide">
);</code></pre>
</div>
+<div class="slide">
+ <h1>More Why Moose?</h1>
+
+ <ul>
+ <li>Less code == fewer bugs</li>
+ <li>Moose is well-tested, test your own code, not Moose</li>
+ <li>Focus on <strong>what</strong>, not <strong>how</strong></li>
+ </ul>
+</div>
+
<div class="slide fake-slide0">
<h1>Part 1: Moose Classes</h1>
</div>
<h1>BUILDARGS</h1>
<ul>
- <li>Takes <code>@_</code>, returns a hash reference of attribute names/value</li>
+ <li>Takes <code>@_</code>, returns a hash reference of attribute name/value pairs</li>
<li>Accepts a hash or hashref; throws otherwise</li>
<li>Provide your own for other cases</li>
<li><strong>Always</strong> call <code>$class->SUPER::BUILDARGS(@_)</code> as a fallback!</li>
<pre><code>Person->new(@_)</code></pre>
- <ol>
+ <ol style="margin-top: 0">
<li>Calls <code>Person->BUILDARGS(@_)</code> to turn <code>@_</code> into a hashref</li>
<li>Blesses a reference</li>
<li>Populates attributes based on the hashref from #1</li>
Undef
Defined
Value
- Num
- Int
Str
+ Num
+ Int
ClassName
RoleName
</pre>
<ul>
<li><code>Value</code> is true when <code>! ref $thing</code></li>
<li><code>Value</code> and <code>Str</code> are effectively the same, but <code>Str</code> is more expressive</li>
+ <li><code>Num</code> is true when a <code>$scalar</code> looks like a number</li>
<li>An overloaded object which numifies does not pass the <code>Num</code> constraint!</li>
<li>Perl 5's overloading is hopelessly broken</li>
</ul>
<h1>Already Mentioned Several</h1>
<ul>
- <li>MooseX::NonMoose - best solution for subclassing non-Moose parents</li>
- <li>MooseX::Declare - <em>real</em> Perl 5 OO</li>
- <li>MooseX::FollowPBP and MooseX::SemiAffordanceAccessor</li>
- <li>MooseX::Params::Validate and MooseX::Method::Signatures</li>
- <li>MooseX::Types</li>
+ <li><code>MooseX::NonMoose</code> - best solution for subclassing non-Moose parents</li>
+ <li><code>MooseX::Declare</code> - <em>real</em> Perl 5 OO</li>
+ <li><code>MooseX::FollowPBP</code> and <code>MooseX::SemiAffordanceAccessor</code></li>
+ <li><code>MooseX::Params::Validate</code> and <code>MooseX::Method::Signatures</code></li>
+ <li><code>MooseX::Types</code></li>
</ul>
</div>
use 5.10.0; # for say
class Person {
- has greeting
- => ( is => 'ro', isa => 'Str' );
+ has greeting =>
+ ( is => 'ro', isa => 'Str' );
method speak {
say $self->greeting;
<li>Still experimental-ish, but seeing more and more use</li>
<li><strong>Not</strong> a source filter!</li>
<li>Hooks into the Perl parser rather than filtering all your code</li>
+ <li>But not supported by <code>PPI</code>, <code>perltidy</code>, etc.</li> (yet?)
</ul>
</div>
<h1>MooseX::StrictConstructor</h1>
<ul>
- <li>By default, unknown constructor arguments are ignore</li>
+ <li>By default, unknown constructor arguments are ignored</li>
<li>MX::StrictConstructor turns these into an error</li>
</ul>
</div>