Recent Changes - Search:

* PCAN

* Phix

edit SideBar

Atom

Index | Library Routines | Predefined Types | atom

atom

Definition: atom identifier

-- or -- integer i = atom(object x)

Description: This serves to define the atom type.

You can also call it like an ordinary function to determine if an object is an atom.

Comments: An atom can hold a single numeric value, ie a floating point or an integer. It can also hold a raw pointer, such as allocated memory or a call_back? address, but that is typically only used when interfacing to external code in a .dll or .so file.

An atom can hold all integer values, but the reverse is not true.

When invoked as a function, returns 1 (true) if x is an atom otherwise returns 0 (false).

Note that atom(x) and not sequence(x) are effectively identical.

Example 1:
atom a
a = 5.99
Example 2:
object line
line = gets(0)
if atom(line) then
    puts(SCREEN, "end of file\n")
end if
Implementation: There are generic versions of the atom function implemented as :%opAtom in builtins\VM\pType.e and :%opAtom0 in builtins\VM\pJcc.e that the compiler only invokes as a last resort, preferring instead to inline that functionality if the argument is known to be assigned or the result variable, if any, is known to be an integer, ie does not require decref/dealloc. The compiler may also completely omit the test and/or any related code, if type inference/propagation determines that the result will always be true or always false.
See Also: integer, sequence, string, object, Atoms, Core Language
Technicalia The sq_atom() routine can be used to apply an atom() test to all top-level elements of a sequence, eg sq_atom({1,1.5,"string",{1,1.5,"string",{}}) ==>; {true,true,false,false}. That routine returns a single true/false if passed an atom or string, otherwise a "flat" sequence of true/false of the same length as the input argument. Note there are no known valid uses of the sq_atom() routine, as yet.
 

< Predefined Types | Index | integer >

Edit - History - Print - Recent Changes - Search
Page last modified on April 16, 2026, at 02:28 AM