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

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

by hardburn (Abbot)
on Nov 29, 2004 at 19:07 UTC ( #411008=note: print w/replies, xml ) Need Help??

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

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.

Replies are listed 'Best First'.
Re^4: The Null Mull (or, when OO needs more O)
by dragonchild (Archbishop) on Nov 29, 2004 at 19:29 UTC
    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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://411008]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2018-03-24 17:00 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (299 votes). Check out past polls.