David,

On Jan 15, 2008 3:59 PM, David Brown <[EMAIL PROTECTED]> 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?


No, not that I'm aware of.


>
> >int *p = &a;
>
>    p++;
>
> or
>    p = (int*) 42;


Sure:

my $p = \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.


Right, I understand this. Gus' definition was strictly limited to saying
pointing to a memory location, not in doing pointer math, or other
manipulation of memory. His comment was correct for Perl, but incorrect for
C because the latter can do those things. I guess I wasn't very clear either
in my response - sorry about that.


>
>
> Usually, even interpreted languages that have C bindings will be able to
> manipulate pointers, but probably in an awkward way.
>
> Dave
>

Perl does have C bindings, but I've never messed around at that level to see
how they work.

-- 
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

Reply via email to