On 21 Sep 2009, at 11:58, Alex Francis wrote:

>    if ( reftype( $param ) && reftype( $param ) eq 'ARRAY' ) {
>
> instead of using CORE::ref
>
>    if ( ref( $param ) eq 'ARRAY' ) {
>
> I mentioned this was what PBP recommended. He asked me what the
> reasoning was, which was the point where I thought "err....."
>
> All I can come up with is that reftype is easier to read because it
> returns what it sounds like it returns, whatever you give it, whereas
> ref returns the class of an object, or if it's not an object then the
> type of a reference.

I have reservations about this, and this would make the second time  
this month where some citation of best practice / perl critic has  
given me pause for thought. (I can't remember the first, off-hand).  
I'm always a little paranoid about dogma.

Perhaps it's just because I'm a fossil, but I can't really see that  
reftype is so much easier to read. The name 'reftype' perhaps  
describes it's purpose more precisely, to an english speaker, but look  
at the samples; it's obvious from context what both routines are  
returning, because of the comparison. Sample B is half the horizontal  
width, contains half as much punctuation, and 50% less function calls.  
Version A requires that you to understand where 'reftype' is declared,  
whereas ref, responds helpfully to a 'perldoc -f', like any built-in.

Unconvinced. Still, it managed to inspire me enough to make me post to  
the list. (/me waves)

-- 
Regards,
Colin M. Strickland
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Reply via email to