
Matt Calabrese wrote:
On Tue, May 31, 2011 at 2:49 PM, Lorenzo Caminiti <lorcaminiti@gmail.com>wrote:
For example, I _think_ (but I've not implemented this yet) that I can simplify the syntax like this:
Looks good, I use pretty much exactly the same syntax in my library concerning parameter lists and templates ( https://github.com/boostcon/2011_presentations/raw/master/thu/Boost.Generic.... slides 79 and 96 are okay examples). The only thing I'm confused about is how you
Thanks, I'll take a look.
specify the return type of your CONTRACT_FUNCTION -- in particular, you did not wrap it in parentheses. Are you really able to do that, or is that a
If the return type is a "keyword" known a priori like void then no parenthesis should be needed. I'd parse it using the pp PP_IS_UNARY to first check if there are parenthesis. If there are no parenthesis then I'd check if the token is a known "keyword" type `void`, `int`, `double`, etc using macros like BOOST_DETAIL_PP_KEYWORD_IS_VOID_FRONT and strip it aways from the front using macros like BOOST_DETAIL_PP_KEYWORD_VOID_REMOVE_FRONT (see http://svn.boost.org/svn/boost/sandbox/local/boost/detail/preprocessor/keywo...). So, this does not need the parenthesis because int is a "keyword" known a priory (void return type also belongs to this category): CONTRACT_FUNCTION( public int (size)() ... ) This instead needs the parenthesis because my_own_size_type is a user-defined type and it's not known a priory: CONTRACT_FUNCTION( public (my_own_size_type) (size)() ... ) Also this needs the parenthesis because int* contains a non-alphanumeric symbol * that cannot be handled by the BOOST_DETAIL_PP_KEYWORD_XXX macros (because they use pp concatenation): CONTRACT_FUNCTION( public (int*) (size)() ... ) The same applies to all specified types including function parameter types `void (f)( int x, int y )` vs. `void (f)( (int*) x, int y )`.
mistake? If that syntax is indeed possible, then I'd like to see the implementation because I too would love to be able to rid myself of some parentheses.
I have done some experimentation that indicates this syntax _should_ be possible but it's not actually implemented yet so... we'll see :) --Lorenzo -- View this message in context: http://boost.2283326.n4.nabble.com/contract-syntax-redesign-tp3563993p356438... Sent from the Boost - Dev mailing list archive at Nabble.com.