
On Fri, Apr 30, 2010 at 7:00 PM, vicente.botet <vicente.botet@wanadoo.fr> wrote:
From: "Lorenzo Caminiti" <lorcaminiti@gmail.com>
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: http://sourceforge.net/tracker/?group_id=253844&atid=1330818 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 check. 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>) (invariant)( (empty() == (size() == 0)) ) ) public: CONTRACT_FUNCTION( (public) (void) (push_back)( (const T&)(element) ) (copyable) (precondition)( (size() < max_size()) ) (postcondition)( (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. CONTRACT_FUNCTION( (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. CONTRACT_FUNCTION( (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). (precondition)( (x != 0) // Default importance order of 0. (find(x))(importance)(100) // Importance order of 100. ) Compiling with -DCONTRACT_CHECK_IMPORTANCE_MIN=0 -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 CONTRACT_CONFIG_ALWAYS_CHECK_ASSERTION_SYNTAX is #defined (but still 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: http://sourceforge.net/tracker/?group_id=253844&atid=1330818 Regards, -- Lorenzo