David Brown wrote:
On Tue, Jan 15, 2008 at 03:54:54PM -0800, Mark Schoonover wrote:
The way I understand it all is that C pointers and Perl refs are the
same,
atleast in creating them.
my $ref = \$a
If you try to do arithmetic on a ref, it turns into an integer. Can Perl
cast that back to a reference?
int *p = &a;
p++;
or
p = (int*) 42;
Where's the difference?
The difference between references and pointers is that a language with
references will only allow you to assign those references to valid things.
Pointers can be arbitrarily manipulated.
Usually, even interpreted languages that have C bindings will be able to
manipulate pointers, but probably in an awkward way.
I suggest reading the man page perlreftut. It clarifies what Perl
references are and why they exist. In particular, references exist due
to a deficiency in Perl originating in Perl 4 that didn't allow a hash
to have anything other than a scalar as a value.
Gus
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg