[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] why address called reference?



At 01:41 -0700 5/14/98, Xah Lee wrote:
>may be off topic:
>
>Why does Perl call memory address references? e.g. "$xx is a reference to
>an array", instead of "$xx is an address of an array".
>
>Is is a convention or is there a technical reason?

In assembly languages (including C :-), it is possible to take the address
of an item, mess with it, then "dereference" it as desired.  For instance,
you could increment the address of a string to get to a particular byte.

A "reference", in Perl (and some other languages), is similar, but more
restrained.  You can only dereference it, and then only for the type of
item it "thinks it has".  This keeps programmers out of trouble, allows
them to ask the language what kind of "thingy" is referenced, etc.

-r

Rich Morin, Canta Forda Computer Laboratory | Prime Time Freeware - quality
  UNIX consulting, training, and writing    | freeware at affordable prices
  P.O. Box 1488, Pacifica, CA, 94044, USA   | www.ptf.com      info@ptf.com
  rdm@cfcl.com            +1 650-873-7841   | +1 408-433-9662   -0727 (Fax)



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch