Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
laziness, impatience, and hubris
 
PerlMonks  

Re^2: The Null Mull (or, when OO needs more O)

by dragonchild (Archbishop)
on Nov 29, 2004 at 18:55 UTC ( #411006=note: print w/ replies, xml ) Need Help??


in reply to Re: The Null Mull (or, when OO needs more O)
in thread The Null Mull (or, when OO needs more O)

Hrmm ... 5.8.4/Solaris doesn't seem to do the right thing.

BEGIN { &Internals::SvREADONLY(\undef, 0); undef = 42; &Internals::SvREADONLY(\undef, 1); } my $x = undef; print( ((undef) ? 'True' : 'False'), $/); print( ((defined undef) ? 'True' : 'False'), $/); print( (($x) ? 'True' : 'False'), $/); print( ((defined $x) ? 'True' : 'False'), $/); -------------- True True False False
Maybe the code isn't actually affecting SV_UNDEF as you think ...

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.


Comment on Re^2: The Null Mull (or, when OO needs more O)
Download Code
Re^3: The Null Mull (or, when OO needs more O)
by hardburn (Abbot) on Nov 29, 2004 at 19:07 UTC

    I just ran your code on 5.8.4 i686-Linux with the same result you did. I'm not sure what is going on here--someone with more understanding of the internals is needed. My guess is that undef isn't staying shared like I expected it would.

    It does work with taking a reference to undef, but this breaks the transparency I was hoping for:

    BEGIN { &Internals::SvREADONLY(\undef, 0); undef = 42; &Internals::SvREADONLY(\undef, 1); } my $x = ${ \undef }; print( ((undef) ? 'True' : 'False'), $/); print( ((defined undef) ? 'True' : 'False'), $/); print( (($x) ? 'True' : 'False'), $/); print( ((defined $x) ? 'True' : 'False'), $/); print $x, $/; __OUTPUT__ True True True True 42

    "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      BEGIN { &Internals::SvREADONLY(\undef, 0); undef = 42; &Internals::SvREADONLY(\undef, 1); } use constant UNDEF => ${ \undef }; my $x = UNDEF;

      Which is probably better because you're commenting that you did something funky with undef. *shrugs*

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2014-04-19 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (478 votes), past polls