Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: Benchmark of hash emptiness test

by Hofmator (Curate)
on Nov 10, 2006 at 10:55 UTC ( [id://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.

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2024-03-29 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found