Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: Determining whether a value is zero.

by Fox (Pilgrim)
on Mar 11, 2011 at 13:17 UTC ( [id://892652]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Determining whether a value is zero.
in thread Determining whether a value is zero.

isn't dualvar's made by peeking at the internals ? I think it's unfair to try to detect something without the same techniques used to create that something, but hey it's your challenge.

On a unrelated note, is dualvar(undef,"string") zero ?

Replies are listed 'Best First'.
Re^4: Determining whether a value is zero.
by JavaFan (Canon) on Mar 11, 2011 at 15:36 UTC
    isn't dualvar's made by peeking at the internals ?
    Eventually, everything Perl is done by doing something with the internals. However, all dualvar exposes is that values can have both a numeric and a string value. One could change large parts of the internals without having to change the interface of dualvar. However, the solution presented queries internal bits of the SV structure.
    is dualvar(undef,"string") zero ?
    Yes. There's no way to store "undef" in the IV slot of an SV. AFAIK, the undef has been (auto)cast to 0 before the SV will be created.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-19 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found