From:   yitzle <[EMAIL PROTECTED]>
> On 10/10/07, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> > > Anyhow, the point is that Perl doesn't have those confusing weird
> > "pointer"
> > > stuff. $a and $c do not "point" to the same place, the just got the same
> > > value. (Well, Perl /does/ have pointers, but... whatever.)
> >
> > Yeah, it does seem you are pretty confused by pointers in C. And
> > probably by references in Perl too. I wonder how can you program
> > without understanding pointers/references, but whatever.
> >
> > Jenda
> 
> 
> The purpose of my message was to clarify the part of the documentation that
> Kaushal asked about.

I think you failed on that.

> I am aware that Perl has pointers/references, as I mentioned, but the
> question is not /about/ pointers, but variables.

Then why did you start about C pointers? Why the C at the all? The 
int variables in C work exactly the same scalars work in Perl and the 
C pointers work (almost) exactly the same as the references in Perl. 

And BTW ... you are aware of the fact that if you do

int *b;
*b = 5;

you cause the program to crash, right?
You did not start by assigning a variable to a reference to 
something, you assigned to the thing already referenced by a 
variable. And unlike Perl, C doesn't "autovivify" the pointer. It 
doesn't notice that the b doesn't point to anything yet and doesn't 
initialize the pointer. And will try to access the address 0.

> The documentation seems to be contrasting variables to pointers. Rather than
> introducing perl references, I thought I could use a bit of C to explain how
> it is possible that by changing $b, you affect $a, and then say with normal
> Perl variables (I know, the word "normal" is wrong) do not exhibit this
> behavior.

This might make some sense if Kaushal knew C already. And I don't 
think it's the case.

> I was trying to avoid being overly technical and trying to explain the
> concept in a way that someone unfamiliar with pointers or references would
> be able to understand them.
> 
> How did my code indicate to you that I am confused about C pointers? It
> looks pretty correct to me...
> And Perl references? I mention they exist, but tried avoiding talking about
> them in this explanation. I use references and pointers in programming, but
> in this explanation, I believe I dealt with them correctly.

It was not so much the code, but the comments.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to