Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • by jdporter (36) on 2002.11.07 11:40 (#14569) Homepage Journal
    They really are different. If nothing else, the two terms are meaningful at different levels of abstraction.

    An associative array is a source language level concept. It means an array which is indexed by arbitrary, unordered values, typically (but not necessarily) strings.

    A hash table is a data structure in which keys are crunched through a hashing function in order to get the actual index used in the table. This is to handle both the unordered-ness and the sparseness of keys.

    Associative arrays need not be implemented with hash tables, and hash tables need not be manifest in the source language (e.g. perl) as associative arrays. This is just how Perl happens to do it.

    It is true that "hash" is therefore not an entirely accurate name for the perl variable type, but it's a lot shorter. Also, if you squint, "%" looks rather like "a/a" (as well as like "H").
    • An associative array is a source language level concept. It means an array which is indexed by arbitrary, unordered values, typically (but not necessarily) strings.

      A hash table is a data structure in which keys are crunched through a hashing function in order to get the actual index used in the table. This is to handle both the unordered-ness and the sparseness of keys.

      Correct me if I'm wrong, but to add to this I believe important distinction that a hash value is a number created by a function which ef