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

Re^3: how ! operator works

by arkturuz (Curate)
on Feb 04, 2011 at 09:12 UTC ( #886159=note: print w/replies, xml ) Need Help??

in reply to Re^2: how ! operator works
in thread how ! operator works

That refcount (2147483647) looks strangely familiar. Is that a coincidence or just a hack in the interpreter so it (the object in question) never gets destroyed by the garbage collector (theoretically)?

Replies are listed 'Best First'.
Re^4: how ! operator works
by bart (Canon) on Feb 04, 2011 at 14:20 UTC
    That refcount (2147483647) looks strangely familiar.
    Just print it out in hex and you'll see:
    which is a clear indication that this is the largest positive integer you can stuff into a signed 32 bit integer (2's complement).

    So yeah, your guess is very likely correct.

Re^4: how ! operator works
by ikegami (Pope) on Feb 04, 2011 at 20:48 UTC

    So I looked at the code to answer your question. It looks like it's a hack, not a magical value. The refcount can go down, but it gets reset back to the max for SvIMMORTAL variables (the true, the false, the undef and a special internal thing called "placeholder").

      So I looked at the code to answer your question.

      Thanks! I searched the code myself today with no luck. I postoponed it for the weekend but now you have resolved this, I'll just have to stick to something else to do :)
        My answer is more or less an educated guess. If you want to look around to confirm or for fun, PL_sv_no is the SV returned when a builtin wants to return something false. An interesting puzzle would be to see if you can manage to lower the refcount and display it at the lower refcount using Devel::Peek's Dump.
Re^4: how ! operator works
by moritz (Cardinal) on Feb 04, 2011 at 09:44 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://886159]
[stevieb]: Torturing one of my dev RPis to turn four 5v stepper motors at the same time (via Parallel:: ForkManager for 50k degrees (a whole lot of full turns!). Let's see if it burns out or not.
[stevieb]: My GPIO expander chips should arrive tomorrow, but I think I'll throw a shift register against them and see if all six I have will turn at once. Amps are near the breaking point, but I want to know max sustainable V and I output.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2018-03-22 22:16 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (286 votes). Check out past polls.