in reply to RFC: Sub::Auto - lazy loading revisited (now: AutoReloader)
Careful! This is a lot stricter than you may want it to be:
UNIVERSAL::isa($ref,'CODE') or $ref = \&{$h -> {'function'}};Setting aside the fact that UNIVERSAL::isa() is a method and not a function, you're disallowing blessed coderefs (perhaps unnecessarily) and you're forbidding overloading (definitely unnecessarily).
If you really need to check that the underlying reference is to a subroutine, use Scalar::Util's reftype(). If all you want to do is check that you can use something as a subroutine reference appropriately, use:
if ( eval { defined &$ref } ) { ... };
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: RFC: Sub::Auto - lazy loading revisited
by shmem (Chancellor) on Feb 20, 2007 at 10:46 UTC | |
Re^2: RFC: Sub::Auto - lazy loading revisited
by ysth (Canon) on Feb 20, 2007 at 07:19 UTC |
In Section
Meditations