Subject: Re: [boost] [log][phoenix] Questions on porting to phoenix
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2012-01-24 22:31:33


On Wednesday, January 25, 2012 08:20:02 Joel de Guzman wrote:
>
> Now, what I advocate is exposing the typedef:
>
> attribute_keyword< tag::severity > severity_type;
>
> and letting the user create a local (function scope) object himself:
>
> boost::log::severity_type severity;
>
> The typing involved is the same. With namespace scope objects, the
> "best-practice" is for you to put these objects in a spacial
> namespace and hoist it into the client namespace using using
> declarations anyway (e.g.):
>
> using boost::log::severity;
>
> The compile time problem is very significant that in Spirit and indeed
> in Phoenix-3, we have special PP defines to disable the predefined
> objects (e.g.):
>
> #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS

Interesting, thanks for the info. But these keywords are to be user-defined
and the whole point behind them is to reduce typing and simplify Boost.Log
usage. For instance, I also plan to support this syntax for extracting an
attribute value from a log record:

  optional< my_severity > sev = rec[severity];

Having to declare a local keyword variable for this seem inappropriate.

But I can make the keyword creation optional by providing several macros for
keyword registration - one that only defines the keyword type and another one
that also creates the keyword. Also, I can put the declared keyword in a
namespace and let the user decide whether he wants to import it by using
declaration or not.