Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How to kill perl?

by diotalevi (Canon)
on Nov 04, 2005 at 18:21 UTC ( #505824=note: print w/replies, xml ) Need Help??


in reply to How to kill perl?

unpack "P", ~0

Why doesn't unpack "P", 0 dump? I expected it to and this confused me.

Replies are listed 'Best First'.
Re^2: How to kill perl?
by robin (Chaplain) on Nov 04, 2005 at 18:35 UTC
    Why doesn't unpack "P", 0 dump? I expected it to and this confused me.

    The reason (on some level) is that pp_unpack() calls newSVpvn(), which calls sv_setpvn(), which has this code:

    if (!ptr) { (void)SvOK_off(sv); return; }
    In other words, unpack("P", 0) just returns an undefined SV. Since C code often uses null pointers in the same way that Perl code uses undef, I think this is more useful than crashing. :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-12-03 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?