Boost logo

Boost :

Subject: Re: [boost] [contract] next round of development
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2010-05-01 08:14:13

On Fri, Apr 30, 2010 at 7:00 PM, vicente.botet <vicente.botet_at_[hidden]> wrote:
> From: "Lorenzo Caminiti" <lorcaminiti_at_[hidden]>
>> FYI, I am starting the next round of development of Boost.Contract.
>> Most of the planned modifications derive from feedback I have received
>> from this mailing list -- thanks!
>> My goal is to request Boost.Contract formal review after this round of
>> development and related documentation updates.
>> You can check the planned development items at:
>> Comments are always welcome.
> Hi Lorenzo,
> it would be better if you added here the important tasks

Sure, this is the list of the main development tasks.

1) Comply with n1962 assertion disabling policies. Specifically,
preconditions will disable nothing (unless a configuration macro is
#defined). Also, nested function calls will not disable invariant
2) Modify CONTRACT_FUNCTION() to also declare the function signature.
CONTRACT_FUNCTION_DEF() instead will follow the C++ function
declaration (same as the current CONTRACT_FUNCTION() implementation).
However, there is only one class-level contract macro,
CONTRACT_CLASS(), which never declares the class.
3) Move bases classes in CONTRACT() and automatically detects when a
function subcontracts (using introspection).
4) Make syntax same as n1962 plus extra preprocessor parenthesis
(i.e., removing CONTRACT_ASSERT() macro, etc).

    template<typename T>
    class myvector: public pushable<T> {

        CONTRACT_CLASS( (myvector) (pushable<T>)
            (empty() == (size() == 0))
        ) )

        (public) (void) (push_back)( (const T&)(element) ) (copyable)
                (size() < max_size())
                (size() == (CONTRACT_OLDOF(this)->size() + 1))
            vector_.push_back(element); // Original implementation.
        }) )


5) Support concepts (interface with Boost.ConceptCheck). Adopt
ConceptC++ syntax plus extra preprocessor parenthesis.

    (template)( (typename)(T) )
        (requires)( (Copyable<T>) (Comparable<T>) ) // Concepts.
    (void) (f)( (const T&)(x) )

6) Support named parameters (interface with Boost.Parameter) -- adopt
`(in)/(inout)/(out)/etc` parenthesized syntax.

    (void) (f)( (in)(const int&)(x) ) // Now x is named so you can
call `f(_x = 10)`...

7) Support assertion importance ordering. This allows to tag and
disable checking of individual or groups of assertions (it was
specified in a previous revision of n1962, and n1962 still indicates
this feature as "relevant" but not required).

        (x != 0) // Default importance order of 0.
        (find(x))(importance)(100) // Importance order of 100.

-DCONTRACT_CHECK_IMPORTANCE_MAX=99 will check `x != 0` but NOT
`find(x)` precondition even if -DCONTRACT_CHECK_PRECONDITION.

8) Always compile assertion code to check its syntax if
do not check assertions at runtime based on CONTRACT_CHECK_... and
importance ordering).

9) Try to reduce compilation-time -- most of the time required to
compile contracts comes from the preprocessor time needed to parse the
parenthesized syntax...

10) Make the library thread safe if CONTRACT_CONFIG_THREADING is #defined.

11) Try to fix issue that causes infinite recursion if a derived
function invokes its base function without CONTRACT_BODY().

More development tasks and details at:



Boost list run by bdawes at, gregod at, cpdaniel at, john at