Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Dualvars besides $! (boring)

by tye (Sage)
on Jan 28, 2014 at 02:16 UTC ( #1072308=note: print w/replies, xml ) Need Help??


in reply to Re: Dualvars besides $!
in thread Dualvars besides $!

IMHO, that's a rather stupid interpretation of "dualvar". If the string value equals the stringification of the other value (IV or NV), then it shouldn't be considered a "dualvar". But then, that's what one would expect from a lazy XS function. A Perl version would just do 0+$x eq $x instead.

!1 doesn't need to be implemented as a dualvar. $x=''; {no warnings; 0+$x;} is also enough to get you what is needed for !1 (a string value of '' and a numeric value of 0 w/o a warning). The canonical value for !1 that Perl uses happens to be a real dualvar, though. But "both an empty string and zero" isn't enough to imply "dualvar".

Win32::TieRegistry can use dualvars.

Update: To be clearer, a Perl version of isdual() would be:

sub isdual { my( $v ) = @_; no warnings; return 0 if int $v ne $v^'0' # No IV nor NV in value || $v eq 0+$v # Cached string just same as IV/NV || $v == "$v" # Cached number just same as 0+PV ; return 1; }

- tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072308]
help
Chatterbox?
[Corion]: I found Android Studio quite nice as a Java IDE, but then, I didn't try anything serious with it
[chacham]: it is a nice ide. its just that upgrading it always causes issues with mismatched versions of whatever
[Corion]: chacham: Oh, yes, reinstalling all the SDK versions and Gradle and whatnot, yes, even in the short time I used it (2 weeks?) I felt that pain
[chacham]: right now im editing the versions in the applications gradle file to use a version it wants. sheesh.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-03-29 07:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (344 votes). Check out past polls.