C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] [isocpp-sg21] Telecon to review P2388R1 Minimum Contract Support: either Ignore or Check_and_abort

From: Aaron Ballman <aaron_at_[hidden]>
Date: Thu, 23 Sep 2021 09:25:33 -0400
On Thu, Sep 23, 2021 at 9:07 AM Jₑₙₛ Gustedt via Liaison
<liaison_at_[hidden]> wrote:
>
> Hello,
>
> on Thu, 23 Sep 2021 01:10:21 +0200 you (Corentin via Liaison
> <liaison_at_[hidden]>) wrote:
>
> > On Wed, Sep 22, 2021, 21:41 Gašper Ažman via Liaison <
> > liaison_at_[hidden]> wrote:
> >
> > > Personally I'm not married to the current grammar, but we do need a
> > > plausible alternative, and we need it soon.
> > >
> > > An alternative syntax needs to have:
> > > - an obvious terminator (a comma is not that, especially for assert)
> > > - somewhere to do the preamble (pre:, post r:, assert: )
> > > - not be current valid syntax.
> > >
> > > Thinking out loud here, but could braces work?
> > >
> >
> > The previous suggestions about
> >
> > pre: :
> > post :
> > assert:
> >
> > can only conflict with labels.
> > A quick scan of the vcpkg repository (649389 files) does not show any
> > conflict
> > And that syntax seems reasonable to me.
> > It's about the same as the current syntax with no [[ ]], if I
> > understand correctly.
>
> If we seek interface compatibility with C, a function-like syntax with
> a keyword or identifier and then plain old parenthesis is always the
> easiest. C can then work around such things with macros that map such
> a beast do whatever is convenient on the target platform.

I agree, but there is a wrinkle here that we need to be careful of.
One of the contract conditions is an assertion that's currently
spelled `assert`, and `assert` followed by an open paren is going to
be an issue due to the `assert` macro. Using context sensitive
keywords like above help sidestep that issue by avoiding the open
paren. Other alternatives exist (like using `Assert` instead of
`assert`, etc).

~Aaron

> C++ clearly has such kind of syntax already (e.g `throw`) and this
> strategy has worked out well in the past, e.g in shared system
> headers.
>
>
> Thanks
> Jₑₙₛ
>
> --
> :: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
> :: ::::::::::::::: office Strasbourg : +33 368854536 ::
> :: :::::::::::::::::::::: gsm France : +33 651400183 ::
> :: ::::::::::::::: gsm international : +49 15737185122 ::
> :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
> _______________________________________________
> Liaison mailing list
> Liaison_at_[hidden]
> Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/liaison
> Link to this post: http://lists.isocpp.org/liaison/2021/09/0791.php

Received on 2021-09-23 08:25:50