|
nkr
A C++20 library with a custom meta-programming language.
|
nkr contains many specific terms which both expand upon standard C++ definitions and bring new concepts to the table. All terms are heavily linked to the abstract designs of the library. When the name of a term coincides with the name of a standard term, it is assumed the reader is already familiar with the standard definition which the term implies in addition to any explicity expanded definition. In the event confusion of terms may occur, the definition of an nkr term will clarify any conflation with or any deviation from standard definition.
The glossary is of great aid when first becoming acquainted with the library and contains short and to-the-point definitions to boost your understanding. It is heavily linked throughout all the documentation, and so you are encouraged to proceed with the reference material as you see fit, and you may rely on the links to terms as they occur during your reading. Otherwise a table of contents is provided to the right, for your convenience.
An alias refers to a standard C++ type alias, template alias, or a template template alias ad infinitum. Aliases are frequently found in the first type section of types, templates, and template templates ad infinitum. They are also used to define the primary entity of the identity for each interface. When aliasing template parameters, thanks to the label postfix design, aliases often keep the same base name as their respective parameters. In the nkr::cpp namespace, standard C++ types and templates are directly aliased as primary entities for their respective identities.
A base name is the left-hand side of a label and is frequently repeated among the labels of entities of the same identity, generic, or file group. Like postfixes, base names may be repeated even in the same namespace, but only with different postfixes. Not to be confused with a base type name.
A capacity is the number of units that will fit within an allocated memory space. This is wholly distinct from a unit count which is the number of units in use within the limits of the capacity. A capacity may sometimes be referred to as a total unit count.
A complement is a related static function, method, operator, or caster that completes the functionality of its relations. For example, a type can have a set of [methods] with the same name but different qualifications for this, or a set of static function may exist that covers logical operators such as OR and NOR.
An entity is an indivisibly unique subject represented by a uniquely named label. Types, templates, template templates ad infinitum, tags, traits, interfaces, functions, methods, files, and more all all entities.
An entity group is an abstraction over multiple and related entities so that they may be easily referenced in unison. Identities, generics, and namespaces are all examples of entity groups. Most entity groups are defined by their own file group and are thus easily identifiable when glancing through the program's hierarchy. However, even file groups themselves are considered entity groups.
A file is an entity representing an atomically indivisible part of the library, such as a standard C++ header or translation unit. It does not need to be a file type oriented to the C++ language. It can be any file with a unique label.
A file group is an abstraction of multiple and related files that define an entity group. The label of each file in the file group shares the same label as that of the primary entity being defined, including its base name and postifx. In addition to this label, most files in the file group have a second postfix to indicate the specific role of the file. The primary file entity is the only file in the group that does not have a second postfix but rather shares the same exact label as that of the primary entity being defined in the file group. Including the primary file entity is an easy way for users to include nkr functionality into their code while ignoring other files in the file group.
A function is an entity that can never be used as the primary entity in an entity group. Unlike most other entities, functions do not have a postfix in their labels, however each word in their name is capitalized to distinguish functions from other entities. Instead of using functions as primary entities, the public namespaces or other entities that contain functions should be used. This is to avoid file label collisions on disk, which may not respect the capitalization of labels. All function labels have no postfix.
A generic is an entity group representing one or more commonalities that exist between different identities or other generics. A typical generic can represent an entire public namespace of identities, such as nkr::generic::array_tr representing nkr::array or nkr::generic::boolean_tr representing nkr::boolean. However, only those identities which satisfy the generic's constraints can be represented by the generic, whether they be in the same public namespace or not. Another typical use of generics is to represent any identity which implements a particular interface, tag, or other highly generalized component. The primary entity of a generic depends on whether it is a type generic, a template generic, or a template template ad infinitum generic, but in every case the primary entity is a generic trait of one sort or another. A generic is distinctly opposed to an identity which represents and centers around a type, template, or template template ad infinitum.
A generic tag is a tag that can be used to represent a generic primary entity in place of the generic entity itself. This is particularly useful for generics because their primary entities are traits and thus they cannot directly be passed to a template parameter list.
A generic trait is a trait used to constrain inputs to multiple identities which must each satisfy specific qualities defined by the generic. This is opposed to an identity trait which constrains to a single identity. A generic trait may also constrain to any number of other generics.
An identity is an entity group representing a singularly unique type, or all instantiated types of a singularly unique template or all instantiated types of a singularly unique template template ad infinitum. This entity group consists of the primary entity, one or more identity traits, and one or more identity tags. All public types, templates, template templates ad infinitum, and interfaces in nkr have an identity. An identity is distinctly opposed to a generic which cannot be an identity.
An identity tag is a tag used to represent a singular identity, which is opposed to a generic tag which represents multiple identities. An identity may have any number of tags including an identity type tag, an identity template tag, and an identity template template ad infinitum tag.
An identity trait is a trait used to constrain inputs to a singular identity, which is opposed to a generic trait which constrains inputs to multiple identities.
A label is the result of combining a base_name, a postfix and any relative namespaces or directories on disk, in order to uniquely distinguish an entity from other entities. Labels are not to be confused with label labels which themselves are entities representing labels. A few exceptions exist regarding the use of postfixes: neither public namespace labels, private namespace labels, nor function labels have postfixes. In order to distinguish public namespaces from private namespaces, a unique suffix is used on the private, whereas function labels have every word capitalized. With the singular exception of private namespaces, no label may use a $ in its name.
A label label is a type with a postfix of _lb representing a label. They are used to describe various entities in the meta-program and are frequently found as inner types of tags. All label labels have the _lb postfix.
A literal value is a type instance of a built-in type, a C++ literal type, or potentially a C++ literal overload.
A postfix is the right-hand side of a label and is frequently repeated among the labels of entities throughout the entire library. Like base names, postfixes may be repeated even in the same namespace, but only with different base names. The label postfix design is a critical component to the structure of nkr.
A primary entity is the most important entity in an entity group. Depending on the context, a primary entity may be a type, a template, a template template ad infinitum, a trait, an interface, a namespace, or a file. The primary entity is always used as the base name for each file group.
A private namespace is a namespace not intended or designed for use by code including nkr functionality. Like private methods on types, private namespaces allow for implementation details that are more subject to change than their public counterparts. Unlike their method cousins however, private namespaces also allow for the avoidance of label collisions for the most common of implementation names. Most private namespaces have a complementing public namespace with the same name, so in order to avoid label collisions private namespaces always have a $ suffixed on the end of their label indicating the private nature of the namespace. All private namespaces otherwise have no postfix.
A public namespace is a namespace that contains entities available for public consumption. This is distinct from a private namespace which contains internally hidden entities used to provide functionality to publicly available entities. Any given public namespace may also have a private namespace working alongside it, and the two must share the same label except that the private namespace is made distinct by the addition of a $ suffixed to its label. All public namespaces have no postfix.
A tag is a type, a template, or a template template ad infinitum that is used as a surrogate to represent a primary entity in the meta-program, especially within template parameter lists. They may represent other types, templates, template templates ad infinitum, or they may represent traits or interfaces. They play an important role in side-stepping limitations of the meta-program and the limitations of a few abstractions. For example, a trait cannot be passed through a template parameter list, but a tag can be. In the case of built-in abstractions, a tag may be used to represent identities that are otherwise syntactically non-representable, e.g. nkr::pointer::cpp_tg can be used in place of *, and nkr::array::cpp_tg for [], notably without any capacity. A tag always has at least one label label as an inner type so as to be identifiable, especially regarding what kind of primary entity it represents. All tags end with the _tg postfix.
See capacity.
A trait is a standard C++20 concept used to constrain types, templates, and template templates ad infinitum. There are three kinds of traits, namely identity traits, generic traits, and interface traits. Almost every primary entity in the library defines at least one trait, and the nkr::generic namespace in particular defines a numerous amount of them. Traits are a first-class citizen in nkr::tr expressions through use of their related types, templates, and tags. All traits end with the _tr postfix.
A type section is an artificial group of similar entities found on type, template, and template template ad infinitum declarations.
A unit is a contextually indivisible type instance of a unit_t, which is a commonly used label for a primary inner type of outer types that work with more than one instance of their primary inner type, such as arrays, linked lists, hash-maps, and allocators.
A unit count is the number of units that are currently occupying a capacity. This is wholly distinct from a capacity which is the total number of units that can fit within the limits of a memory space. Not to be confused with a total unit count which is another name for capacity.