]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/proto/doc/rationale.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / proto / doc / rationale.qbk
CommitLineData
7c673cae
FG
1[/
2 / Copyright (c) 2008 Eric Niebler
3 /
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 /]
7
8[section:rationale Appendix C: Rationale]
9
10[/==================================================]
11[section:static_initialization Static Initialization]
12[/==================================================]
13
14Proto expression types are PODs (Plain Old Data), and do not have constructors. They are brace-initialized, as follows:
15
16 terminal<int>::type const _i = {1};
17
18The reason is so that expression objects like `_i` above can be ['statically
19initialized]. Why is static initialization important? The terminals of many embedded
20domain-specific languages are likely to be global const objects, like `_1` and
21`_2` from the Boost Lambda Library. Were these object to require run-time
22initialization, it might be possible to use these objects before they are
23initialized. That would be bad. Statically initialized objects cannot be misused
24that way.
25
26[endsect]
27
28[/=========================================================]
29[section:preprocessor Why Not Reuse MPL, Fusion, et cetera?]
30[/=========================================================]
31
32Anyone who has peeked at Proto's source code has probably wondered, "Why all the
33dirty preprocessor gunk? Couldn't this have been all implemented cleanly on top of
34libraries like MPL and Fusion?" The answer is that Proto could have been
35implemented this way, and in fact was at one point. The problem is that template
36metaprogramming (TMP) makes for longer compile times. As a foundation upon which
37other TMP-heavy libraries will be built, Proto itself should be as lightweight as
38possible. That is achieved by prefering preprocessor metaprogramming to template
39metaprogramming. Expanding a macro is far more efficient than instantiating a
40template. In some cases, the "clean" version takes 10x longer to compile than the
41"dirty" version.
42
43The "clean and slow" version of Proto can still be found at
44http://svn.boost.org/svn/boost/branches/proto/v3. Anyone who is interested can
45download it and verify that it is, in fact, unusably slow to compile. Note that
46this branch's development was abandoned, and it does not conform exactly with
47Proto's current interface.
48
49[endsect]
50
51[endsect]