Date: Mon, 20 Sep 2021 20:44:30 +0000
Am Montag, den 20.09.2021, 22:23 +0200 schrieb Jens Maurer:
> On 20/09/2021 21.51, Uecker, Martin wrote:
> > But if we adopt this syntax for contracts, shouldn't
> > we add generic syntax such as:
> >
> > [[attribute-token : conditional-expression]]
> >
> > instead of having only "pre", "post", and "assert"?
> > Then future extensions would benefit from syntax
> > (and type?) checking even with older compilers.
>
> I'm not good enough looking into the future to anticipate
> whether all future extensions in that area will necessarily
> have a condition-expression after the introducer.
We should probably make it in an expression in the
general case (specific forms could narrow it down).
> I do notice that the current proposal on the table for C++
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2388r2.html
>
> uses "[[post r: r >= 0]]" to designate the return value as "r".
> That would be incompatible with your proposed generic grammar.
Good point, but we could simply make the grammar more generic.
[[attribute-token identifier-list_opt : expression]]
(or whatever is needed)
So I guess my proposal is to have a generic syntax-checked
version of attributes in addition to regular attributes.
This seems useful to me, because we could add new features
that benefit from syntax checking with older compilers (or
non-standard attributes). Yes, if we later go beyond this
syntax, this will not work. But then we are in the same
position as without this.
Martin
> On 20/09/2021 21.51, Uecker, Martin wrote:
> > But if we adopt this syntax for contracts, shouldn't
> > we add generic syntax such as:
> >
> > [[attribute-token : conditional-expression]]
> >
> > instead of having only "pre", "post", and "assert"?
> > Then future extensions would benefit from syntax
> > (and type?) checking even with older compilers.
>
> I'm not good enough looking into the future to anticipate
> whether all future extensions in that area will necessarily
> have a condition-expression after the introducer.
We should probably make it in an expression in the
general case (specific forms could narrow it down).
> I do notice that the current proposal on the table for C++
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2388r2.html
>
> uses "[[post r: r >= 0]]" to designate the return value as "r".
> That would be incompatible with your proposed generic grammar.
Good point, but we could simply make the grammar more generic.
[[attribute-token identifier-list_opt : expression]]
(or whatever is needed)
So I guess my proposal is to have a generic syntax-checked
version of attributes in addition to regular attributes.
This seems useful to me, because we could add new features
that benefit from syntax checking with older compilers (or
non-standard attributes). Yes, if we later go beyond this
syntax, this will not work. But then we are in the same
position as without this.
Martin
Received on 2021-09-20 15:44:37