Boost logo

Boost :

Subject: Re: [boost] [contract] syntax redesign
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2011-09-27 14:29:33

> I think option B (current) is still better than option A because A
> (1) more parenthesis and (2) the extra assertion word spelled out all the
> times but A doesn't require the trailing `,` which is a plus.

> Do you have a strong opinion about which one is better between A and B?
> say B is better but I'm quite biased at this point ;)

Hi Lorenzo,
Since you ask about personal preference, I think mine is option A. I can
think of the following reasons:

* Given the fairly complicated syntax for Boost.Concepts, option A appears
to me to add more structure to the declaration, and makes parsing it easier.
Especially that I imagine you could further simplify it:
  instead: var(auto old_size = CONTRACT_OLDOF size())
  could be: var( old_size = CONTRACT_OLDOF size() )

* Since you put each assertion (or declaration) in a separate line anyway
option B appears also elegant, but if someone starts putting multiple
assertions in the same line, I think option A would be clearer. Compare:

  postcondition( x - 1 == y + 2, y - 1 == z + 2 )
  postcondition( assert(x - 1 == y + 2) assert(y - 1 == z + 2) )

* If anyone writes a tool for generating documentation from Contracts, I
think parsing would be easier with option A.

* In option A, it is easier to tell assertions from declarations, I can
easily count how many things are asserted

* I suspect that you can use commas more freely inside assertion(), which
reduces the necessity of using "identity" function workaround.

But I could hardly call it a strong opinion. It is just my preference, and I
will like Boost.Contract with either syntax.


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