Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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]
[Corion]: erix: I'm not sure if it really is MySQL - maybe MS SQL also has LIMIT 0
[erix]: it has TOP, IIRC
[Corion]: erix: Ah. I use where 1 = 0 for queries where I only am interested in the structure ;)
[erix]: 1=0 is as short as TOP :)
[erix]: "code of someone that died" -- kinda nice if your code stops working too
[erix]: hard to implement, hmm
[Corion]: erix: Well, they also seem to have changed the server, or some software, or whatever, and seem to be in the process of changing the DB schema from having the "username" as primary key to something else.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2017-01-23 09:32 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (192 votes). Check out past polls.