Skip to content

Namespaces

Namespaces are containers within the kdb+ workspace. Names defined in a namespace are unique only within the namespace.

Namespaces are a convenient way to divide an application between modules; also to construct and share library code.

Namespaces are identified by a leading dot in their names.

System namespaces

kdb+ includes the following namespaces.

namespace contents
.h Functions for converting files into various formats and for web-console display
.j Functions for converting between JSON and q dictionaries
.m Objects in memory domain 1
.Q Utility functions
.q Definitions of q keywords
.z System variables and functions, and hooks for callbacks

The linked pages document some of the objects in these namespaces. (Undocumented objects are part of the namespace infrastructure and should not be used in kdb+ applications.)

These and all single-character namespaces are reserved for use by KX.

Names

Apart from the leading dot, namespace names follow the same rules as names for q objects.

Outside its containing namespace, an object is known by the full name of its containing namespace followed by a dot and its own name.

Namespaces can contain other namespaces.

Thus .fee.fi.fo is the name of object fo within namespace fi within namespace fee.

Dictionaries

Namespaces are implemented as dictionaries. To list the objects contained in namespace .foo:

key `.foo

To list all the namespaces in the root:

key `

Construction

Referring to a namespace is sufficient to create it.

q)key `
`q`Q`h`j`o
q).fee.fi.fo:42
q)key `
`q`Q`h`j`o`fee
q)key `.fee
``fi
q)key `.fee.fi
``fo

\d
Q for Mortals ยง12 Workspace Organization