]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/vmd/doc/vmd_dynamic_typing.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / vmd / doc / vmd_dynamic_typing.qbk
CommitLineData
7c673cae
FG
1[/
2 (C) Copyright Edward Diener 2011-2015
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt).
6]
7
8[section:vmd_dynamic_typing Input as dynamic types]
9
10Within the constraints based on the top-level types which VMD can parse,
11the libraries gives the end-user the ability to design macros with
12dynamic data types. By this I mean that a macro could be designed to handle
13different data types based on some documented agreement of different combinations
14of macro input meaning slightly different things. Add to this the ability
15to design such macros with variadic parameters and we have a preprocessor
16system of macro creation which to a lesser extent rivals the DSELS of template
17metaprogramming. Of course the preprocessor is not nearly as flexible as
18C++ templates, but still the sort of preprocessor metaprogramming one could
19do with VMD, and the underlying Boost PP, in creating flexible macros which
20can handle different combinations of data types is very interesting.
21
22Of course macros need to be usable by an end-user so the syntactical ability
23of sequences to represent different types of input data must
24be balanced against ease of use and understanding when using a macro. But because
25certain sequences can mimic C++ function calls to some extent it is possible
26to represent macros as a language closer to C++ with VMD.
27
28What is important when designing a macro in which you parse input to decide which type
29of data the invoker is passing to your macro is that you are aware of the constraints
30when parsing a data type. As an example if you design a macro where some input can either
31be a number, an identifier, or some other data type top-level input then attempting
32to parse the data to see if it is a number or identifier could fail with a preprocessor
33error and nullify your design if the data is not a VMD data type. So designing a macro with
34data types in mind often means restricting data to parseable top-level types.
35
36[endsect]