I have encountered the ATOM
type in the Win32api and also in the Acrobat API there is ASAtom.
As far as I can tell, atoms are keys for a hash table usually of strings to enable fast look up and share data between applications. Is this correct and what is the etymology of the atom type?
EDIT
After some extensive searching I noticed Prolog uses atoms, so there must be some origin to this word. It seems it used to refer to any single piece of data.
As for the etymology of the name
ATOM
, I know I've once seen it in some old Microsoft Win32 API documentation that it is an acronym of "Access to Memory" or something like that. It is a term used for simple numerical identifiers (other name is "handles") which represent some internal data structures in the system.From obvious reasons, it wouldn't be smart to give the user direct pointers to these structures. First, because they reside in kernel space, and second, because it violates encapsulation. The user could then just free the memory which doesn't belong to it, or overwrite it, or some other stupid ideas. So the operating system simply gives it some replacement number tag (that's the ATOM), which then could be used to request the data from the system. It's also faster for the user to pass around the little number instead of the whole huge data structure. Users don't need to care about memory allocations & stuff, or accessing some data through pointers which are no longer valid, which could simply crash their programs.
The RegisterClass / RegistrClassEx functions (and a few others) return an ATOM data type.
The ATOM uniquely identifies the class being registered, but if the function fails it returns zero, so you can test if the function has failed like this
ATOM is a 16-bit Windows handle-like primitive. It's value is completely opaque to user-mode. It is not a pointer or an index.
typedef unsigned short ATOM;
The earliest thing I can find about the term "atom" is from the Lisp programming language (source). However, it probably originally came from mathematical logic. In programming they are also called Symbols and at its simplest form are name integers (an enumerated type in C would be an example). However, they are widely used in many programming languages and in the Win32 API and Acrobat API they are identifiers for strings in a table.
Also, as Mehrdad points out, the original meaning in Greek is "indivisible", so they imply a primitive data type which cannot be broken down any further.