Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^4: Benchmark of hash emptiness test

by Hofmator (Curate)
on Nov 10, 2006 at 10:55 UTC ( #583319=note: print w/replies, xml ) Need Help??

in reply to Re^3: Benchmark of hash emptiness test
in thread Benchmark of hash emptiness test

Pardon my ignorance (I don't know much about the perl internals) but I was under the impression that there was something like boolean context. So shouldn't the hash in if (%hash) {} be able to tell that it was used in boolean context and thus react accordingly? This should then be an easy patch, just defining a different behaviour for %hash in boolean (in contrast to scalar) context.

-- Hofmator

Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^5: Benchmark of hash emptiness test
by demerphq (Chancellor) on Nov 10, 2006 at 13:02 UTC

    Well there is no G_BOOL defined, so i dont think internally we have a boolean context. I think what you are thinking of is overloading, which has a bool conversion operator, but the scalarification of a hash in a conditional doesn't involve overloading.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://583319]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2023-03-20 21:55 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (59 votes). Check out past polls.