> It's taken me a while to wrap my head around > references, since I thought they were always > Perl-specific. (At least, the term 'reference' doesn't > show up in K&R!) > > Anyway, it finally occurred to me that the term > 'reference' might just be Perlish for what other > languages (C, I'm thinking) call a 'pointer'... Am I > totally out of wack?
Yes, and no. In C, a pointer points directly to memory. Specifically, it points to a single memory location. Therefore, adding and subtraction has meaning for pointers, since you move memory location relative to current position... however, there are some problems. This scheme means all memory in use by the application can be manipulated, including the program itself. This leads to security issues, as well as the fact the programmer might make a mistake in their pointer arithmetic and change the wrong thing. In Perl, and some other languages, a reference is an anonymous name for a data structure. Hence it points to a block of memory, moreover it can only be manipulated by Perl itself. A reference cannot meaningfully be manipulated as a pointer can... furthermore, a refered to data structure only disappears when it's reference count is zero. This avoids a common situation in C programming called a dangling pointer - which occurs when memory is freed that the pointer still points to. > Is the distinction in the docs somewhere that I could > read about a bit? Probably embedded someplace in: perldoc perlref Jonathan Paton __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]