Boost logo

Boost :

Subject: Re: [boost] [contract] Macro syntax?
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2010-03-27 22:27:09


Hello,

I would like to renew the request for all of you to express an opinion
between OPTION 1 and 2 below. I am NOT asking you to understand
Boost.Contract. On the contrary, the less you know about
Boost.Contract the more your input is valuable for me.

Please just indicate which syntax between OPTION 1 and 2 you would
like the most (or dislike the least ;) ) to see in your header files.

On Sat, Mar 20, 2010 at 10:54 AM, Lorenzo Caminiti
<lorcaminiti_at_[hidden]> wrote:
> OPTION 1: The function declaration is programmed using the usual C++
> syntax just before the CONTRACT_FUNCTION() macro.
>
>    template<typename T>
>    class myvector {
>
>        CONTRACT_INVARIANT( ({
>            ...
>        }) )
>
>    public:
>        void push_back(const T& element) // Usual C++ push_back() declaration.
>        CONTRACT_FUNCTION( (class) (copyable)(myvector)
>                (public) (void) (push_back)( (const T&)(element) )
>        (precondition)({
>            ...
>        })
>        (postcondition)({
>            ...
>        })
>        (body)({
>            ...
>        }) )
>
>        ...
>    };
>
> OPTION 2: The CONTRACT_FUNCTION() macro automatically programs also
> the function declaration.
>
>    template<typename T>
>    class myvector {
>
>        CONTRACT_INVARIANT( ({
>            ...
>        }) )
>
>    public:
>        // No usual C++ push_back() declaration here.
>        CONTRACT_FUNCTION( (class) (copyable)(myvector)
>                (public) (void) (push_back)( (const T&)(element) )
>        (precondition)({
>            ...
>        })
>        (postcondition)({
>            ...
>        })
>        (body)({
>            ...
>        }) )
>
>        ...
>    };

Thanks a lot!
Lorenzo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk