Organization

| Home | Libraries | People | FAQ | More

## Organization

Care and attention to detail was given, painstakingly, to the design and implementation of Phoenix.

The library is organized in four layers:

The modules are orthogonal, with no cyclic dependencies. Lower layers do not depend on higher layers. Modules in a layer do not depend on other modules in the same layer. This means, for example, that Bind can be completely discarded if it is not required; or one could perhaps take out Operator and Statement and just use Function, which may be desireable in a pure FP application.

The library has grown from the original Phoenix but still comprises only header files. There are no object files to link against.

## Core

The lowest two layers comprise the core.

The `Actor` is the main concept behind the library. Lazy functions are abstracted as actors. There are only 2 kinds of actors:

1. Primitives
2. Composites

Primitives provide the basic building blocks of functionality within Phoenix. Composites are used to combine these primitives together to provide more powerful functionality.

Composites are composed of zero or more actors. Each actor in a composite can again be another composite.

Table 1.2. Modules

Module | Description
--- | ---
Function | Lazy functions support (e.g. `add`)
Operator | Lazy operators support (e.g. `+`)
Statement | Lazy statments (e.g. `if_`, `while_`)
Object | Lazy casts (e.g. `static_cast_`), object creation destruction (e.g. `new_`, `delete_`)
Scope | Support for scopes, local variables and lambda-lambda
Bind | Lazy functions from free functions, member functions or member variables.
Container | Set of predefined "lazy" functions that work on STL containers and sequences (e.g. `push_back`).
Algorithm | Set of predefined "lazy" versions of the STL algorithms (e.g. `find_if`).

Each module is defined in a header file with the same name. For example, the core module is defined in `<boost/spirit/home/phoenix/core.hpp>`.

Table 1.3. Includes

Module | File
--- | ---
Core | `#include <boost/spirit/home/phoenix/core.hpp>`
Function | `#include <boost/spirit/home/phoenix/function.hpp>`
Operator | `#include <boost/spirit/home/phoenix/operator.hpp>`
Statement | `#include <boost/spirit/home/phoenix/statement.hpp>`
Object | `#include <boost/spirit/home/phoenix/object.hpp>`
Scope | `#include <boost/spirit/home/phoenix/scope.hpp>`
Bind | `#include <boost/spirit/home/phoenix/bind.hpp>`
Container | `#include <boost/spirit/home/phoenix/container.hpp>`
Algorithm | `#include <boost/spirit/home/phoenix/algorithm.hpp>`