On Jan 15, 2008 4:53 PM, David Brown <[EMAIL PROTECTED]> wrote:
> On Tue, Jan 15, 2008 at 04:09:02PM -0800, Mark Schoonover wrote:
>
> >> p = (int*) 42;
> >
> >my $p = \42;
>
> Um, no, that creates a box with a 42 in it, and stores a reference to the
> 42 in $p. The C code sets the pointer to 42. You can't have a Perl
> reference that doesn't point to a real Perl object, at least not without
> calling out to C.
>
> In perl
>
> print $$p, "\n";
>
> prints 42. The C code.
>
> printf ("%d\n", *p);
>
> SEGFAULTs. Very different.
>
> Dave
>
> --
> [email protected]
> http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
>
Speaking of segfaults: http://xkcd.com/371/
>From what I'm learning here is, references inside VMs are not exactly the
same as C pointers. That extra layer of indirection provided by the VM stops
anything 'funny' from going on to protect against segfaults.
--
Mark Schoonover, CMDBA
http://www.linkedin.com/in/markschoonover
http://marksitblog.blogspot.com
[EMAIL PROTECTED]
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg