in reply to Re: Reference assessment techniques and how they fail
in thread Reference assessment techniques and how they fail
Good point, but there's actually another problem I forgot to mention. In a &{}, undef is code.
use strict; use warnings; use Test::More 'tests' => 3; sub is_code { no warnings qw( void uninitialized ); return eval { defined &{$_[0]}; 1 }; } sub real_sub { die 'real sub called' } my $sub_ref = sub { die 'sub ref called' }; my $undef; ok( is_code( \&real_sub ), 'real sub ref is code' ); ok( is_code( $sub_ref ), 'lexical sub ref is code' ); ok( is_code( $undef ), 'undef is code' );
This isn't a big deal, I guess. We just have to change is_code to return defined $_[0] && eval { defined &{$_[0]}; 1 };. Still, I'd rather call something that figures out what it is than call it to figure out what it is.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Reference assessment techniques and how they fail
by shmem (Chancellor) on Feb 17, 2008 at 19:04 UTC | |
by kyle (Abbot) on Feb 17, 2008 at 19:50 UTC |