<div style="font-family: Helvetica; font-size: 13px; "><br></div>
<div></div>
<p style="color: #A0A0A8;">Le mardi 11 décembre 2012 à 21:16, David Golden a écrit :</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div><blockquote type="cite"><div><div>Hm you're right, I had not realized it'd be for *every* route. Indeed we</div><div>need more benchmark here :) But I like the attribute style. If it can help</div><div>in decision making, catalyst makes use of them as well, and it's rather</div><div>elegant.</div></div></blockquote><div><br></div><div>Attribute style might be visually nice, but the implementation of</div><div>attributes in Perl is really ugly hackery and many people (myself</div><div>included) who have gotten into the weeds have concluded that it's just</div><div>not worth the trouble.</div><div><br></div><div>Personally, I would find the style below just as appealing if not more</div><div>because it's guaranteed to follow Perl's grammar:</div><div><br></div><div> get '/beer' => requires_role BeerDrinker => sub { ... };</div><div><br></div><div> get '/user/:user_id' => requires_role qw/Admin TeamLeader/ => sub { ... };</div><div><br></div><div>Plus, I can do this:</div><div><br></div><div> my @power_users = qw/Admin TeamLeader/;</div><div><br></div><div> get '/user/:user_id' => requires_role @power_users => sub { ... };</div><div><br></div><div>You can't as easily do that with attributes because attribute</div><div>parameters are strings that have to be parsed -- typically split on</div><div>whitespace. You *could* parse looking for "@\w+" and then eval() it,</div><div>but (a) that's gross and (b) you've got timing issues because the</div><div>attribute is processed at compile time and the array isn't populated</div><div>until runtime.</div><div><br></div><div>And consider if you want to put your role names in a config file</div><div>instead of the source code. How do you do that with attributes?</div></div></div></span></blockquote><div>Use a huge BEGIN for parsing the config file ? :) Just kidding </div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div><div><div><br></div><div>Have I convinced the doubters by now? :-)</div></div></div></span></blockquote><div>I'm convinced :)</div><div><br></div><div><br></div>