Feedback:N4415 Simple contracts for C++

已查看 82 次
跳至第一个未读帖子

germandi...@gmail.com

未读,
2015年4月17日 04:18:192015/4/17
收件人 std-pr...@isocpp.org
Hello everyone,

I would like to give some feedback on the proposal.

I think the proposal is quite reasonable and in essence very similar to Walter E. Brown's proposal N4435

N4415 suggests to have switches for turning on-off validation, in case the runtime does validate something.
This leaves things as an all-or-nothing feature, meaning that if you don't check preconditions,
you will not check any. For me, it makes sense that we don't check is_sorted + is_permutation after sorting,
but it is valuable to check for container !empty() and similar conditions.


   I think there should be a way to leave cheap preconditions in code
   always enabled.
   The use case for this is that bugs occur. There are pre and
   postconditions that are worth to be left enabled even in production
   environments, saving valuable debugging time should a problem occur.

   Therefore, I would suggest to augment expects and ensures with
   expects_always and ensures_always (or similar) for checks
   that will always be performed, not affected by the contract
   switches.


Best Regards

回复全部
回复作者
转发
0 个新帖子