[jifty-devel] Janitorial: lib/Jifty/Request.pm

Edgar Whipple jifty at misterwhipple.com
Sat Mar 3 14:12:48 EST 2007


Okey doke. I'll back out the rejected changes in Request.pm, and make
note of the policy decisions. 

On Sat, 2007-03-03 at 17:25 +0000, Jesse Vincent wrote:
> On Mar 3, 2007, at 5:15 PM, Edgar Whipple wrote:
> > If no
> > objection, I'll also add a suggestion about coders using format- 
> > skipping
> > tags (#<<<, #>>>) to preserve manual layout in small areas.
> 
> I'd rather review the output of tidying than pollute the source with  
> these
Doing so makes sense. And I'm not proposing that we add those tags
anywhere during cleanup, only that it would be good to mention them in
the docs as an option for when the coder wants to signal "Hey, cleanup
guys: don't lose the visual layout of this block." They're just comment
lines, I expect they'd rarely be used, and they avoid the risk of being
overlooked.



> > Come to think of it, perhaps a good item on the janitorial list  
> > would be
> > identifying the scalar-only subs and marking them with 'return  
> > scalar'.
> >
> 
> "return scalar"?

I got that from PBP p186-188. If a sub should always return a scalar
value, use 'return scalar $foo;' instead of 'return $foo;'. It cuts down
the complications when someone mistakenly calls the sub in list context.
Depending on the return expression, plain 'return $foo' in list context
can yield a really off the wall value, one that makes troubleshooting
the caller's error more difficult.

'return scalar $foo;' also makes the always-a-scalar intention explicit
to someone reading the code for the first time.


> 
> use warnings;
> use strict;
> package A;
> $x++;
> package B;
> $y++;
> 1;

Cool; now I know. Thanks.

Edgar
-- 
ln -s /dev/null ~/.sig



More information about the jifty-devel mailing list