use constant SUBJECT => 'Defining Constants'; # was: !0
Peter Haworth
pmh at edison.ioppublishing.com
Fri Feb 13 15:25:32 GMT 2009
On Fri, 13 Feb 2009 13:49:37 +0000, Paul Makepeace wrote:
> > On 13 Feb 2009, at 13:05, Andy Wardley wrote:
> >>
> >> use Badger::Constants 'ARRAY HASH';
> >>
> >> if (ref $foo eq ARRAY) {
> >> ...
> >> }
> >> elsif (ref $foo eq HASH) {
> >> ...
> >> }
>
> Since you're calling a sub, and the goal is to reduce typing,
> why not just have,
>
> if (IS_ARRAY($foo)) {
> ...
> }
Because you're not actually calling a sub. Constant "subs" are optimized to
strings at compile time. That said, I think I like your alternative better;
it's more concise, and the intent is a lot clearer.
--
Peter Haworth pmh at edison.ioppublishing.com
"You, not being an idiot, fail to think like an idiot could. This is a
major cause of confusion in the world. Try to think like an idiot more."
-- John Redford
This email (and attachments) are confidential and intended for the addressee(s) only. If you are not the intended recipient please notify the sender,
delete any copies and do not take action in reliance on it. Any views expressed are the author's and do not represent those of IOP, except where specifically
stated. IOP takes reasonable precautions to protect against viruses but accepts no responsibility for loss or damage arising from virus infection.
For the protection of IOP's systems and staff emails are scanned automatically.”
Institute of Physics Registered in England under Registration No 293851
Registered Office: 76/78 Portland Place, London W1B 1NT
More information about the london.pm
mailing list