Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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.


Comment on Re^4: Benchmark of hash emptiness test
Select or Download Code
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.

    ---
    $world=~s/war/peace/g

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2014-07-31 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls